LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-23-2009, 06:56 PM   #1
DT (D_Turmined)
LQ Newbie
 
Registered: Sep 2007
Posts: 3

Rep: Reputation: 1
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
 
Old 03-24-2009, 05:18 AM   #2
DT (D_Turmined)
LQ Newbie
 
Registered: Sep 2007
Posts: 3

Original Poster
Rep: Reputation: 1
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.
 
Old 03-24-2009, 09:47 AM   #3
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 163Reputation: 163
Quote:
Originally Posted by DT (D_Turmined) View Post
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.
 
Old 03-24-2009, 09:53 AM   #4
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
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
 
Old 03-25-2009, 07:46 AM   #5
DT (D_Turmined)
LQ Newbie
 
Registered: Sep 2007
Posts: 3

Original Poster
Rep: Reputation: 1
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error: Error for wireless request "Set Mode" (8B06) : invalid argument "roaming" penguin chick Linux - Wireless Networking 5 08-22-2008 01:16 PM
plesk + php 4.3.2 upgrade error - "undefined symbol: ap_signal" p_s_shah Linux - Server 0 10-30-2007 12:41 PM
LXer: Interview with Pavel Kanzelsberger ("Pixel" developer) LXer Syndicated Linux News 0 10-18-2006 05:54 PM
CUPS Error "Request Entity Too Large" When Adding/Modifying Printer liquidrabbit Linux - Software 1 06-09-2006 10:16 AM
Problems burning ISO Images - error message "data does not match" Joe Bloggs Linux - Newbie 2 08-22-2004 09:28 PM


All times are GMT -5. The time now is 02:29 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration