Dynamically cropping and resizing images with Flash and GD
We're currently working on a project that uses a combination of Flash and GD/PHP to allow users to upload a photo and crop it dynamically using a Flash interface.Once the user is happy with the cropped image, they simply click 'save' and GD creates the cropped image and saves it on the server.
The main problem we've come across is that GD requires sufficient memory limits in php.ini for image resizing. If somebody uploads an image that is too big, GD can't process it because it runs out of memory.
In years gone by, the best solution probably would have been to set a size limit for uploaded photos of 500kb.
However with digital cameras and phone cameras becoming increasingly powerful, more and more of our users are uploading much larger files, and a limit of 500kb just isn't really enough.
So luckily we can use an .htaccess file to increase the memory allocation and allow GD to process larger images.
We've added the following line of code to an .htaccess file in the folder with the PHP/GD script:
php_value memory_limit 128M
That solved the problem and means that our visitors can now create thumbnails from images of up to 2Mb in size.
Labels: gd crop flash php
0 Comments:
Post a Comment
<< Home