LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   php.ini "upload_max_filesize 2meg" error on large pixel images under 1meg (https://www.linuxquestions.org/questions/linux-newbie-8/php-ini-upload_max_filesize-2meg-error-on-large-pixel-images-under-1meg-713915/)

DT (D_Turmined) 03-23-2009 06:56 PM

php.ini "upload_max_filesize 2meg" error on large pixel images under 1meg
 
Hi All,

Hope my first question is ok here, im new on forums and little understanding of php/linux.

In a php script we use the function "CreateUploadedImageResized" to resize up to 5 images uploaded by a user via http, and we make 3 copies of each image re-sized to 96, 320, 800 (max) pixels.

- php.ini "upload_max_filesize" is set to 2meg
- php.ini "post_max_size" is set to 12meg
- timeout is set to 60 seconds

However, if images are much over 1200 pixels they fail to upload and the script crashes rendering a blank white screen, even though the images are only 600kb (well under the 2meg limit), but a 2mb image at 1200 pixels will upload successfully. Often users try to upload 2000-3000 pixel images each at 1meg (typical of digital cameras) and they always fail.

Any ideas? TIA. DT

DT (D_Turmined) 03-24-2009 05:18 AM

Image dimension limits imposed by php-GD library
 
Further research has revealed image dimension limits are imposed by php-GD library, because graphic manipulation can take large amounts of memory.

Is there a config file somewhere for the gd module that (safely) allows larger pixel files? TIA.

rweaver 03-24-2009 09:47 AM

Quote:

Originally Posted by DT (D_Turmined) (Post 3485929)
Further research has revealed image dimension limits are imposed by php-GD library, because graphic manipulation can take large amounts of memory.

Is there a config file somewhere for the gd module that (safely) allows larger pixel files? TIA.

/etc/php5/conf.d/gd.ini is the only config file outside of the php.ini that I know of and it's not relevant, you should be able to modify it's behavior by utilizing the [gd] section in the php.ini file. I don't know the syntax off the top of my head though.

ilikejam 03-24-2009 09:53 AM

Guessing here, but I'd check the:
memory_limit = ?M
setting in php.ini. My Wiki install needs that setting to be ~4x the biggest file it's likely to see.

Dave

DT (D_Turmined) 03-25-2009 07:46 AM

php memory limit requires 4 bytes per pixel
 
Thank you for the answers. Indeed php.ini "memory_limit" was the answer, if it helps anyone else here is the answer explained:

The Image: 1 pixel needs 4 bytes (32 bits) if alpha-channel is used, and in our situation we exceeded Allowed memory size of 52,428,800 bytes, as follows :

3680 x 2760 pixels = 10,156,800 pixels x 4 bytes = 40,627,200 bytes (remember it's a crude estimate)

So in php.ini we're going to:
- increase "upload_max_filesize" to 3M (meg)
- increase "post_max_size" to 16M (total upload per script)
- increase "memory_limit" to 64M (meg)
- increase "max_execution_time" to 90 (seconds)

Tested 5 x 2.5meg 3680x2760 pixel images and all is now fine:)

Also checked the load on the server via ssh (command: top, result: %id).

Thank you again and hope this helps others.


All times are GMT -5. The time now is 12:43 PM.