Uploading Very Large Images

Limits on uploading files

The ability to upload and import images into your Pixaria Gallery library has some limits which are defined by how PHP is set up on your web server.

The maximum size of any file (such as a JPEG image) that you can upload to Pixaria is dependent on the file upload_max_filesize limit setting in the php.ini configuration file on your server. Files larger than this size, cannot be uploaded to Pixaria without changing this setting.

Limits on resizing large images

Importing large images into Pixaria Gallery involves resizing them into the screen resolution (comping) and thumbnail images you see when you browse Pixaria.

The maximum size of any image that you can import into Pixaria once it's been uploaded is dependent on three factors:

  1. Whether or not ImageMagick is installed on your web server (see below)
  2. The dimensions of the image in pixels. This determines how much memory will be used during the resizing process.
  3. The amount of memory PHP (and thus Pixaria) can use at one time.

The amount of memory used to resize an image depends on the number of pixels in the image. Larger image dimensions mean that more memory will be needed.

Solutions to resizing problems

The following solutions can be used to help resolve problems importing images due to memory restrictions in PHP.

Check ImageMagick is installed

For best results importing images, ask your hosting company whether they will install ImageMagick for you on your server. ImageMagick is a third party software package that can be used by Pixaria to resize images for use in the gallery software. It has a number of advantages over the GD graphics library which is included with PHP:

  • It is not constrained by PHP memory limits.
  • It produces better quality thumbnails and comping images.
  • It supports more image formats including TIFF, PSD and JPEG 2000.

Ensuring ImageMagick is installed is the simplest way to ensure great results importing images into Pixaria.

Modifying PHP settings to allow larger image uploads

To ensure that you and your users can work effectively with very large images, you may need to increase the limits on various PHP settings by editing the PHP configuration file php.ini on your server.

Note: Modifying the settings in php.ini may cause your site to cease functioning correctly if you make a mistake. Always make a back-up first or consult your hosting company for advice!

If you don't have access to php.ini, some of these settings may also be modified by using a .htaccess file. For help with this, please consult your favourite search engine.

PHP settings for file uploads

;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).

upload_tmp_dir = /Applications/MAMP/tmp/php

; Maximum allowed size for uploaded files.
upload_max_filesize = 32M

The upload_max_filesize setting defines how much data any web page can send to PHP in one go. When you submit a form to your website, the data in the form is encoded before it is sent to the server and any files you attach are included in this. If you have a form with a large image attached, the image will only be accepted by PHP if the total size of all the form data including the attached image is less than the upload limit in PHP's settings. The default for this value is 2 MB.

PHP memory and execution time settings

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

max_execution_time = 30     ; Maximum execution time of script, in seconds
max_input_time = 60    ; Maximum time script may spend parsing request data
memory_limit = 8M      ; Maximum amount of memory a script may consume (8MB)

The memory_limit setting defines how much memory a single PHP script can use at one time. Resizing images requires a lot of physical memory on your web server and larger images need more than smaller ones. The default setting for this in PHP is 8 MB and setting this to a much higher value is recommended if your server supports it.

Maximum execution time:

The max_execution_time defines how long (in seconds) a PHP script has to do everything it needs to. Any script which hasn't finished running its instructions before the end of this time will be aborted irrespective of whether it has finished.

The max_input_time setting defines (in seconds) how long a script can spend processing the data that is sent to it. Any data not processed before this time elapses will be ignored.

PHP form data input settings

; Maximum size of POST data that PHP will accept.
post_max_size = 32M

The post_max_size setting defines the maximum amount of data that can be sent to a PHP script by means of the HTTP 'post' method for sending form data. The 'upload limit' cannot be set to a value higher than this as file uploads are a type of post data.

Troubleshooting modifying settings

  1. If you don't have access to php.ini on your server, speak to your hosting company about changing these settings.
  2. If, after making changes to php.ini, you still have problems importing large images, contact your hosting company, they may have placed their own limits on image uploading and importing.

blog comments powered by Disqus


Last edited on Tuesday November 01 2011 at 06:53:12