PHP Thumbnail Class

拟墨画扇 提交于 2019-12-04 12:26:19

问题


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?


回答1:


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.




回答2:


use class.upload.php

see this link for details may be its help you more

http://www.verot.net/php_class_upload_samples.htm




回答3:


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.



来源:https://stackoverflow.com/questions/4804355/php-thumbnail-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!