1 <?php 2 /** 3 * 缩略图 4 * 5 */ 6 7 8 //创建原图 9 $srcIm = imagecreatefromjpeg('../image/a.jpg'); 10 11 $srcW = imagesx($srcIm); 12 $srcH = imagesy($srcIm); 13 14 $percent = 0.5; 15 16 $desW = $srcW * $percent; 17 $desH = $srcH * $percent; 18 19 //创建新图 20 $desIm = imagecreatetruecolor($desW, $desH); 21 22 //拷贝图像并调整大小 23 //imagecopyresized(); 24 25 //重采样拷贝图像并调整大小 26 imagecopyresampled($desIm, $srcIm, 0, 0, 0, 0, $desW, $desH, $srcW, $srcH); 27 28 //生成图采用jpeg 29 imagejpeg($desIm, "../image/a_{$desW}_{$desH}.jpg", 75); 30 //imagepng($desIm,"../image/a_{$desW}_{$desH}.png");