生成缩略图的php程序

生成缩略图的php程序,宽高减半

 1 <?php
 2 
 3 $filename="./img/img01.jpg";
 4 $src_img = imagecreatefromjpeg($filename);
 5 $src_w = imagesx($src_img);
 6 $src_h = imagesy($src_img);
 7 $dst_w = $src_w*0.5;  //宽高减半
 8 $dst_h = $src_h*0.5;
 9 $dst_img = imagecreatetruecolor($dst_w,$dst_h);
10 imagecopyresampled($dst_img,$src_img,0,0,0,0,$dst_w,$dst_h,$src_w,$src_h);
11 imagejpeg($dst_img,"./img/s_img01.jpg");                   //dst_img 生成缩略图文件(不用header声明)
12 imagedestroy($src_img);
13 imagedestroy($dst_img);

 

posted @ 2022-08-19 18:33  paoPaoLong_liu  阅读(26)  评论(0)    收藏  举报