Page 1 of 1

How do I use Imagick->affineTransformImage()?

Posted: 2008-07-18T11:39:47-07:00
by flashape
I'm trying to transform an image using Imagick->affineTransformImage(), then compose that image onto an existing image. However when I compose the image, it's just positioned at the x,y specified by the call to compositeImage() with no transformation.

Here's what I am attempting:

Code: Select all


$image = new IMagick();
$image->readImageBlob($imageContent);  //$imageContent is image data loaded from another server.

$draw = new ImagickDraw();
$draw->affine( $this->convertFlashMatrix( $frameVO->matrix) ); //$frameVO is an object sent from flash
$image->affineTransformImage($draw);

// layeredImage is a previously existing Imagick object
$this->layeredImage->compositeImage( $image, Imagick::COMPOSITE_OVER, 200, 200);


//converts a matrix object sent from flash to the expected array for ImagickDraw->affine()
function convertFlashMatrix($flashMatrix){
	$imagickMatrix = array();
		
	$imagickMatrix['sx'] = $flashMatrix['a'];
	$imagickMatrix['sy'] = $flashMatrix['d'];
	$imagickMatrix['rx'] = $flashMatrix['b'];
	$imagickMatrix['ry'] = $flashMatrix['c'];
	$imagickMatrix['tx'] = $flashMatrix['tx'];
	$imagickMatrix['ty'] = $flashMatrix['ty'];

	return $imagickMatrix;
		
}
I'm sure I'm missing a step somewhere here, but I can't figure out what it is. Any help is appreciated.

Thanks,

Rich

Re: How do I use Imagick->affineTransformImage()?

Posted: 2008-07-19T19:32:39-07:00
by flashape
i think i figured it out...or actually I figured out a different way to do what I wanted to do:

Code: Select all

$image = new IMagick();
$image->readImageBlob($imageContent);  //$imageContent is image data loaded from another server.

$draw = new ImagickDraw();
//set affine transformation in the imagickdraw object
$draw->affine( $this->convertFlashMatrix( $frameVO->matrix) );

//composite the image i want transformed into the draw object
$draw->composite(Imagick::COMPOSITE_OVER,0,0, -1, -1, $image);

//draw the draw object into the layered image
$this->layeredImage->drawImage($draw);
$draw->destroy();