PHP Thumbnail Class
I am looking for a solid PHP thumbnail generating class. Does anyone know any good ones that ar开发者_C百科e 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?
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.
use class.upload.php
see this link for details may be its help you more
http://www.verot.net/php_class_upload_samples.htm
Generating a thumbnail requires so little code that it is a "simple example" of the GD library's resizing functions in the manual:
http://php.net/manual/en/function.imagecopyresampled.php
Just copy and paste.
精彩评论