Apply affine transform to image

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
jb2b38
Posts: 1
Joined: 2015-10-12T07:43:42-07:00
Authentication code: 1151

Apply affine transform to image

Post by jb2b38 » 2015-10-12T07:55:43-07:00

I'm trying to draw an image on top of another one, at a specified position.

One image is the background, the second one is a PNG with transparency. I'm using transformation matrix to position this image on the picture based on some operations that were calculated beforehand. I'm new to imagick, but I've done some researches and haven't found a solution yet.

Up to now, I was able to draw my image on the background with correct transparency with

Code: Select all

$background->compositeImage($image, imagick::COMPOSITE_ATOP, 0, 0);
but this only positions the picture on top of the previous one, and doesn't let me apply a transform to it.

I've tried to do the following, but didn't get any result:

Code: Select all

$draw = new ImagickDraw();
$draw->affine($affineRotate);
$draw->push();
$image->affineTransformImage($draw);
$draw->pop();	
$background->drawImage($draw);
I read on the PHP documentations here: http://php.net/manual/en/imagick.affine ... mimage.php
that I wasn't the only one not getting results.

I tried to modify code from here: http://phpimagick.com/ImagickDraw/affine
in order to replace the Blue rectangles by my picture, but couldn't figure a way to do so.

Thanks for pointing me to the right direction.

Post Reply