How do I use Imagick->affineTransformImage()?
Posted: 2008-07-18T11:39:47-07:00
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:
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
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;
}
Thanks,
Rich