imagick双线性正向失真最佳拟合不起作用

时间:2018-09-21 11:16:31

标签: imagick

我相信$ bestfit参数在BILINEARFORWARD上不起作用,因为我做了以下测试:

$height = 120;
$width = 168;
$image = new Imagick();
$image->newPseudoImage($width, $height, 'canvas:blue');
$image->setFormat('png');
$image->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
$controlPoints = [
    0, 0, /* to */ 0, 0,
    $width, 0, /* to */ $width, 30, // shifting top right corner 30 pixels down
    $width, $height, /* to */ $width, $height - 30, // shifting bottom right corner 30 pixels up
    0, $height, /* to */ 0, $height
];
$image->distortImage(Imagick::DISTORTION_BILINEARFORWARD, $controlPoints, $bestfit = true);
header('Content-Type: image/png');
echo $image->getImageBlob();

在这种情况下,输出正确,没有问题。

但是,如果我将右下角的控制点更改为:

$width, $height, /* to */ $width, $height + 30, // shifting bottom right corner 30 pixels down

我将获得相同的尺寸(168x120像素),并且由于他位于图像边界之外,因此右下角被裁剪。 这使我相信未应用“ $ bestfit = true”。

如果我将distort方法更改为:

$image->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, $bestfit = true);

我得到了预期的结果,它是新的尺寸(170x152像素),并且具有四个角的完全失真的图像。

我知道manual说,“ 如果启用了'最佳匹配',并且允许失真,那么将调整目标图像以确保整个源'图像'恰好适合最终的目标图片,该图片会相应调整大小并偏移”。 但是我不确定双线性向前是否允许。

如果是这种情况,有人知道解决方法吗?

0 个答案:

没有答案
相关问题