<?php
$image = imagecreatefromjpeg("images/cat.jpg");
$width = imagesx($image);
$height = imagesy($image);
$thumb_width = $width *0.5;
$thumb_height = $height *0.5;
$thumb = imagecreatetruecolor($thumb_width,$thumb_height);//创建一个原图一半大小的画布
var_dump($image);
imagecopyresampled($thumb,$image,0,0,0,0,$thumb_width,$thumb_height,$width,$height);
imagejpeg($thumb,"images/cat_thumb.jpg",100);//将缩略图保存到文件,第三个参数是质量
imagedestroy($thumb);//清除占用内存
$image = imagecreatefromjpeg("images/cat.jpg");
$width = imagesx($image);
$height = imagesy($image);
$thumb_width = $width *0.5;
$thumb_height = $height *0.5;
$thumb = imagecreatetruecolor($thumb_width,$thumb_height);//创建一个原图一半大小的画布
var_dump($image);
imagecopyresampled($thumb,$image,0,0,0,0,$thumb_width,$thumb_height,$width,$height);
imagejpeg($thumb,"images/cat_thumb.jpg",100);//将缩略图保存到文件,第三个参数是质量
imagedestroy($thumb);//清除占用内存