tags:

views:

248

answers:

4
+1  Q: 

PHP Thumbnails

I was looking at a way to dynamically create thumbnails using PHP and GD but everytime i select a large image maybe 10MegaPixels about 4-5MB it gives the error

**images/Surabhi_Cow.jpgimages/tn/Surabhi_Cow.jpg
Fatal error: Allowed memory size of 31457280 bytes exhausted (tried to allocate 10368 bytes) in C:\Program Files\xampp\htdocs\MySite\Staff\test.php on line 51**

Changing the memory_limit in php.ini to 60 does the trick but my host only allows the memory_limit to 32M. What other options do I have to generate thumbnails on the fly? I checked phpThumb() but don't really get it. So any other options are welcome!

+3  A: 

You want to use ImageMagick. It is much more efficient in handling large images than GD.

Paolo Bergantino
Perfect for this and the resampling is great.
Syntax
A: 

Consider using a command-line based approach. For example, you can invoke ImageMagick from the command-line to resize images.

Other than that, in pure PHP, it's hard to see how you can edit images that are larger (in RGB format) than your RAM...

Assaf Lavie
A: 

As the others have said, if the images are that big it's time to drop GD and switch to ImageMagick. One word of warning though: do it all on the command-line - the class wrappers out there are wheels in need of damn good re-inventing, every last one.

+1  A: 

If all you want to do is generate thumbnails. I recommend this nice little script called imagethumb.php. You can download it here:http://www.olivo.net/software/imagethumb/

This script produces excellent thumbnails with absolutely no pixelation. It accepts a height or width argument that you append to the URL that calls the script. It's really really easy to use and comes with documentation (which you'll read for all of 2 minutes).

I tried other thumbnailing scripts such as "ThumbsUp" (for example) before landing on this one. BTW, it also renders .png images and also .gif (if I recall correctly). The cache feature will make it easier on your server if you have large files. Also, I assume that your server has the GD library or ImageMagick installed. Good Luck ;)