//Get current dimensions
$width = imagesx($myimage);
$height = imagesy($myimage);
$width = $width * ($zoom/100);
$height = $height * ($zoom/100);
$scale = min($new_width/$width, $new_height/$height);
$new_width = ceil($scale * $width);
$new_height = ceil($scale * $height);
imagecopyresampled($image_p, $myimage, 0, 0, $offset_x * -1, $offset_y * -1, $new_width, $new_height, $width, $height);
我正在尝试缩放图片,但事实上它变小了,根本没有缩放。缩放是一个因素,如113/100 = 1.13它应该是13%放大。
答案 0 :(得分:1)
我想你想要的是:
//Get current dimensions
$width = imagesx($myimage);
$height = imagesy($myimage);
$new_width = $width * $zoom / 100; //120 zoom will increase the image by 20%
$new_height = $height * $zoom / 100;
imagecopyresampled($image_p, $myimage, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
实际上php.net上的第一个例子是缩放示例:http://php.net/manual/en/function.imagecopyresampled.php