//Isometric scaling of images
//Because PHP can only operate on resources, you need to copy the image that needs to be scaled and create it as a new resource
$src=imagecreatefromjpeg('a.jpg');
//Get the width and height of the source image
$size_src=getimagesize('a.jpg');
$w=$size_src['0'];
$h=$size_src['1' ; Length, get the scaled image width and height
if($w > $h){
$w=$max;
$h=$h*($max/$size_src['0 ']);
}else{
$h=$max;
$w=$w*($max/$size_src['1']);
}
(Target resource, source, start coordinates x, y of the target resource, start coordinates x, y of the source resource, width and height w, h of the target resource, width and height w, h of the source resource)
Imagecopyresampled($image, $src, 0, 0, 0, 0, $w, $h, $size_src['0'], $size_src['1']);
//Tell the browser to parse as an image
header('content-type:image/png');
imagepng($image);
//Destroy resources
imagedestroy($image);
? >
http://www.bkjia.com/PHPjc/326717.html
www.bkjia.com