TimSC
March 19th, 2008, 03:55 PM
I am doing some picture composition with imagick in PHP. I translate the image before I do the composition. Depending on the amount of translation, I can get the image or the script fails. If I translate +1000 in the horizonal direction I get a valid image. If I translate -1000 units, the script fails and I get a zero size result.
I would expect Imagick to throw an exception if there was a problem rather than just silently failing. Most strange.
I am using Imagick 2.1.1, Ubuntu 7.10, PHP Version 5.2.3, Apache 2.2.4, ImageMagick 6.2.4.
<?php
//phpinfo();
//Create a blank blue image
$image = new Imagick();
$col = new ImagickPixel();
$col->setColor ("blue");
$image->newImage( 640, 480, $col );
$image->setImageFormat( 'png' );
//Create a small green image
$col->setColor ("green");
$image2 = new Imagick();
$image2->newImage( 100, 100, $col );
$image2->setImageFormat( 'png' );
//Composit green image onto blue image
$ImagickDraw = new ImagickDraw();
$ImagickDraw->translate(-1000.0,0.0); //Translation step
$ImagickDraw->composite(imagick::COMPOSITE_OVER,0,0,-1,-1,$image2);
$image->drawImage( $ImagickDraw );
//Output image
header( "Content-Type: image/{$image->getImageFormat()}" );
echo $image->getImageBlob( );
?>
Any ideas would be appreciated. Even "it works for me" would be helpful at this stage!
As to why I want to translate by -1000, I am doing some map alignment affine transforms and they can be quite complex - this is just a test case.
Regards,
TimSC
I would expect Imagick to throw an exception if there was a problem rather than just silently failing. Most strange.
I am using Imagick 2.1.1, Ubuntu 7.10, PHP Version 5.2.3, Apache 2.2.4, ImageMagick 6.2.4.
<?php
//phpinfo();
//Create a blank blue image
$image = new Imagick();
$col = new ImagickPixel();
$col->setColor ("blue");
$image->newImage( 640, 480, $col );
$image->setImageFormat( 'png' );
//Create a small green image
$col->setColor ("green");
$image2 = new Imagick();
$image2->newImage( 100, 100, $col );
$image2->setImageFormat( 'png' );
//Composit green image onto blue image
$ImagickDraw = new ImagickDraw();
$ImagickDraw->translate(-1000.0,0.0); //Translation step
$ImagickDraw->composite(imagick::COMPOSITE_OVER,0,0,-1,-1,$image2);
$image->drawImage( $ImagickDraw );
//Output image
header( "Content-Type: image/{$image->getImageFormat()}" );
echo $image->getImageBlob( );
?>
Any ideas would be appreciated. Even "it works for me" would be helpful at this stage!
As to why I want to translate by -1000, I am doing some map alignment affine transforms and they can be quite complex - this is just a test case.
Regards,
TimSC