Class sharing for PHP to generate picture thumbnails
This article mainly explains the "PHP generated picture thumbnail class sharing", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "PHP generated picture thumbnail class sharing" bar!
Note: this feature depends on the GD2 graphics library
Recently, I want to use php to generate thumbnails. I looked for it on the Internet and found this article: PHP generates picture thumbnails.
After trying it out, I found that there are several problems:
1. The thumbnails generated by png images are in jpg format.
2. The thumbnails generated by png images have no transparent (translucent) effect (filled with a black background).
3. The code syntax is old.
Therefore, a simple modification and optimization has been made on the basis of this version.
PHP generates thumbnail classes
Use
When using it, you can directly call the constructor of the class, which is as follows:
$resizeimage = new resizeimage ($imgPath, $width, $height, $isCut, $savePath)
Parameters.
$imgPath: original image address
$width: thumbnail width
$height: high thumbnail
$isCut: whether to cut, Bool value
$savePath: thumbnail address (can be the same as the original image address)
Example
Effect.
Thank you for your reading, the above is the content of "PHP generating picture thumbnail class sharing". After the study of this article, I believe you have a deeper understanding of the problem of PHP generating picture thumbnail class sharing, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!