将 CSS3 rotateY 转换为 PHP Imagick::distortImage

Convert CSS3 rotateY to PHP Imagick::distortImage

我有一个在前端获得 rotateY(-54deg) 的图像,我需要使用 Imagick::distortImage

在 PHP 上以相同的方式旋转它
$image->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, true);

有没有一种简单的方法可以将 -54deg 转换为 distortImage() 需要的 $controlPoints

我认为没有任何(简单的)方法可以做到这一点。

Imagick::DISTORTION_PERSPECTIVE用于使用perspective projection扭曲图像,这需要8个预先计算的系数。

来自imagemagick docs

You can get these coefficients by looking at the -verbose output of a 'Perspective' distortion, or by calculating them yourself. If the last two perspective scaling coefficients are zero, the remaining 6 represents a transposed 'Affine Matrix'.

我认为 -54deg 本身没有足够的数据来破译这 8 个系数。你将不得不以艰难的方式做到这一点,抱歉:)