PHP 图像 使用给定的比例调整大小


PHP Image Resize with the given scale

我有一个用于在浏览器中裁剪图像的JQuery插件。 它的工作问题是我不明白这个"比例"部分。

原始图像尺寸:640x640

J查询断头台插件结果数据:

{ scale: 0.9, angle: 0, x: 10, y: 20, w: 400, h: 400 }

我对规模感到困惑。

[编辑]:

这是我的PHP代码:

$filename = $this->data['img_file'];
$scale = round($this->data['scale'],2);
$angle = 360 - $this->data['angle'];
$x = $this->data['x'];
$y = $this->data['y'];
$w = $this->data['w'];
$h = $this->data['h'];
list($width, $height) = getimagesize($filename);
$new_width = $width * $scale;
$new_height = $height * $scale;
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
$image_s = imagecreatetruecolor(400,400);
imagecopyresampled($image_s, $image_p, 0, 0, $x, $y, $w, $h, 400, 400);

[固定]

缩放

通常会根据百分比调整图像大小。 因此,如果将其保留为 1,它应该保持在 100%,但裁剪图像实际上会从图像中删除像素,而更改比例会缩小或放大图像像素间距。