【问题标题】:jQuery Cropper to PHP Imagick: equivalent of imagecopyresampled in ImagickjQuery Cropper 到 PHP Imagick:相当于 Imagick 中的 imagecopyresampled
【发布时间】:2020-04-30 12:00:31
【问题描述】:

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

cropper parameters

【问题讨论】:

  • 请详细说明您想要达到的目标,您尝试了什么,以及您发现的确切问题。同时,查看 imagemagick 文档:imagemagick.org/script/command-line-options.php
  • 假设你在 jQuery 中有你想要的参数,它是 web 浏览器上的 Javascript,你打算如何将这些参数发送回服务器上的 PHP?

标签: php resize crop imagick


【解决方案1】:

目前通过 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(),我可以通过 Cropper 获得相同的裁剪区域。 假设我想获得最终的 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()的函数来达到同样的效果。

【讨论】:

    猜你喜欢
    • 2016-07-24
    • 2013-08-28
    • 1970-01-01
    • 2014-07-07
    • 2019-05-28
    • 1970-01-01
    • 2015-05-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多