Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Thumbnail Class

I am looking for a solid PHP thumbnail generating class. Does anyone know any good ones that are open-source?

I could write one, but I really don't want to. The one thing I hate most about PHP is manipulating images with GD and Imagemagick.

Does anyone have any suggestions?

like image 843
ATLChris Avatar asked Jan 26 '11 12:01

ATLChris


1 Answers

Use phpThumb(). Its a script that internally uses GD library and/or ImageMagick (whichever is available and whichever it thinks is best for the job) to perform basic image manipulation tasks, including thumbnail generation and square thumbnail generation.

You can use it like this:

<!-- best fit -->
<img src="/phpThumb/phpThumb.php?src=/path/to/image.jpg&w=64&h=64">
<!-- crop fit (square thumbnails) -->
<img src="/phpThumb/phpThumb.php?src=/path/to/image.jpg&w=64&h=64&zc=1">

It has built in caching engine so second time a browser requests the above image it is served from its own cache instead of re-generating the thumbnail every time. Though, you may want to spend an hour or so configuring it.

like image 62
Salman A Avatar answered Oct 19 '22 23:10

Salman A