GD Issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Inkyskin
Forum Contributor
Posts: 282
Joined: Mon Nov 19, 2007 10:15 am
Location: UK

GD Issue

Post by Inkyskin »

Hi all,

Does anyone know if there is a filesize limit that GD can work with?

I have a script that takes an uploaded image and then resizes to various different sizes - but it fails on images around 9mb and larger. The image is uploaded as I can see it on the server, it just isnt touched afterwards.

Thanks :)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

PHP's default memory limit is 8mb. You can temporarily change this using ini_set() or .htaccess.

Code: Select all

ini_set('memory_limit', '64M');
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

PHP also has a max_file_upload limit and a max_post_size limit as well. The file upload limit I believe is 2M while the max post size is 8M by default.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

For a 9mb image you'll want to allow about 128mb for the script. This is 9mb jpeg compressed image x 10 uncompressed while processing and leaving a little room for overhead.
User avatar
Inkyskin
Forum Contributor
Posts: 282
Joined: Mon Nov 19, 2007 10:15 am
Location: UK

Post by Inkyskin »

Thanks all - I have already increased the upload and post size, but the memory limit does need to be increased still.. I'll try that and let you know

Will increasing the memory limit to that much have an effect on the rest of the site at all? Will it slow it down etc?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

If you are using ini_set(), it will only affect the current script. If you want a more site-wide affect then your best bet is editing your php.ini, however if that is not an option you can use .htaccess
Post Reply