Page 1 of 1

Apply affine transform to image

Posted: 2015-10-12T07:55:43-07:00
by jb2b38
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.