Get the App
SLTechnology News&Howtos  ›  Development  › 

How to generate picture thumbnails by php

Shulou Source: shulou.com Published: 2022-06-03 19:45:13 11月11日 Update

This article mainly shows you "php how to generate picture thumbnails", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "php how to generate picture thumbnails" this article.

The details are as follows:

GD2 library is needed here.

Function make_thumb ($src,$dest,$desired_width) {/ * read the source image * / $source_image = imagecreatefromjpeg ($src); $width = imagesx ($source_image); $height = imagesy ($source_image); / * find the "desired height" of this thumbnail, relative to the desired width * / $desired_height = floor ($height* ($desired_width/$width); / * create a new, "virtual" image * / $virtual_image = imagecreatetruecolor ($desired_width,$desired_height) / * copy source image at a resized size * / imagecopyresized ($virtual_image,$source_image,0,0,0,0,$desired_width,$desired_height,$width,$height); / * create the physical thumbnail image to its destination * / imagejpeg ($virtual_image,$dest, 83);} above is all the content of the article "how to generate thumbnails in php". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Pictures generation content articles learning help easy to understand more organization knowledge editing industry information information channels channels research Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Xiaomi macOS Shulou Technology Docker