Home>Article>Backend Development> Generate image thumbnail class written natively in PHP
Generate image thumbnail class written natively in PHP. This article takes JD.com product images as an example to generate images of three different sizes. Calling the method is very simple, just pass the parameters height and width, and the name of the new picture.
Introducing the thumbnail class
##
1 include_once 'ImageResize.class.php';
Generate thumbnails of three different sizes Sketch
//实例化缩略图类 以京东商品为例 $newimage = new ImageResize(); //将当前目录下的test.jpg生成缩略图并保存到test_400_400.jpg,指定的宽度高度分别是400和400像素 $newimage->resize("test.jpg", "test_400_400.jpg", 400, 400); $newimage->resize("test.jpg", "test_200_200.jpg", 200, 200); $newimage->resize("test.jpg", "test_50_50.jpg", 50, 50); //获取最后一条错误信息,如果生成成功则输出'success' echo $newimage->GetLastError();If you want to know more courses, please pay attention to the
PHP video tutorialon the PHP Chinese website!
The above is the detailed content of Generate image thumbnail class written natively in PHP. For more information, please follow other related articles on the PHP Chinese website!