I am trying to change the perspective of the Plane2Cylinder distortion in ImageMagick via PHP.
To help explain what I'm looking for, I've created this graphic:

You can see that the lower part of the red block has a greater radius than the top part, as if you were viewing this from above center.
I have tried the optional center_x/y fields:
$label->distortImage(\Imagick::DISTORTION_PLANE2CYLINDER, [28,0,100], true);
With various settings between 0 and 1000 on each x and y, with zero results.
Anyone have any insights or hints? I've search thoroughly, but can't find anything relevent.
I haven't fount solution with the DISTORTION_PLANE2CYLINDER but just as an idea that a hardcore perspective may reduce the strength of difference and maybe become also a point for further distortions for eg. Circular and Radial Distortion Methods (Arc).

plus
convert img.png \
-matte \
-virtual-pixel transparent \
-distort Perspective '200,0,0,0 100,700,100,700 700,700,700,700 600,0,800,0 ' \
img1.png

May give you desired radius on top and bottom.
I solved this with the following code - works like a charm and delivers the right result. Be aware, the angle also depends on the distance of the viewer, not only on the eye level.
public function renderCyclinderToPlane()
{
//http://www.imagemagick.org/Usage/distorts/#cylinder2plane
$imagick = new \Imagick(realpath($this->distortImageControl->getImagePath()));
$points = array(
70, //fov_angle,
//center_x,y,
//fov_output,
//dest_center_x,y
);
$imagick->setImageBackgroundColor("#fad888");
$imagick->setImageVirtualPixelMethod(\Imagick::VIRTUALPIXELMETHOD_BACKGROUND);
$imagick->distortImage(\Imagick::DISTORTION_CYLINDER2PLANE, $points, true);
header("Content-Type: image/jpeg");
echo $imagick;
}
References / Credits go to:
Also see: How can I apply a pincushion distortion effect on a svg image (in order to read a qr code on round surface reliably)?
If you just want to put an qr code on a glass/jar/bottle, put it on the top or bottom.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With