jQuery Cropper to PHP Imagick:相当于 Imagick 中的 imagecopyresamp



我正在使用jQuery Cropper来获取我在PHP中裁剪图像的参数。我想使用Imagick但我不明白imagecopyresampled的等价物是什么。

裁剪器参数

目前通过 Cropper 的getData()函数,我得到了这些参数:

$dst_x = offset left of the cropped area
$dst_y = offset top of the cropped area
$dst_width = the width of the cropped area
$dst_height = the height of the cropped area.

我通过 ajax 将这些参数传递给 PHP。

使用imagecopyresampled(),我可以通过裁剪器获得相同的裁剪区域。 假设我想获得最终的 240x400 图像。

$crop_width = 240; 
$crop_height = 400; 
$new_image = imagecreatetruecolor($crop_width, $crop_height);
imagecopyresampled($new_image, $source_image, 0, 0, $dst_x, $dst_y, $crop_width, $crop_height, $dst_width, $dst_height);

但是我想使用PHP Imagick进行图像处理,但我找不到类似于imagecopyresampled()的功能来获得相同的效果。

最新更新