在 php Imagick 中更改圆弧方向

Changing arc direction in php Imagick

我在 php 中使用 Imagick 使用 compositeImage 处理和重叠图像,然后弯曲图像的顶部和底部边框。为此,我使用了 DISTORTION_ARC:

$distortPoints = array( 120 );
$img->setImageVirtualPixelMethod( Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
$img->setImageMatte( TRUE );
$img->distortImage(Imagick::DISTORTION_ARC, $distortPoints, FALSE);

这使图像呈弧形,但我希望反转弧形的方向(https://photos.app.goo.gl/1JAthzLBoVsozQy97)。

更新:

我在 Fred 的 ImageMagick 脚本 (http://www.fmwconcepts.com/imagemagick/cylinderwarp/index.php) 中找到了一个脚本,这正是我正在寻找的,但我无法在 php 中使用它。

我不确定我是否理解您在 ImageMagick 中真正想要的效果。但这里有两对例子。第一对使用 -distort arc,第二对使用 -distort barrel。在每一对中,一个图像以一种方式弯曲,另一个图像以另一种方式弯曲。

第二个命令回答了你关于弧线向下弯曲的问题。


convert rose: -virtual-pixel White -distort arc 60 rose1.jpg

convert rose: -virtual-pixel White -rotate 180 -distort arc 60 -rotate 180 rose2.jpg

convert rose: -virtual-pixel White -distort barrel "0.0 0.0 0.0 1.0   0.0 0.0 0.5 0.5"  rose3.jpg

convert rose: -virtual-pixel White -distort barrel "0.0 0.0 0.0 1.0   0.0 0.0 -0.5 1.9" rose4.jpg

这是使用我的 ImageMagick 圆柱化命令将您的图像放到杯子上的结果。

图片:

马克杯:

cylinderize -m vertical -r 73 -l 120 -w 40 -p 5 -n 94 -e 2 -a 0 -v background -b none -f none -o +24+10 stay_home.jpg coffee_mug1.jpg result.jpg

结果:


请参阅我的主页以获取与 PHP exec() 一起使用的指针。

注意:要将我的脚本用于商业目的,您需要就许可问题与我联系。