trying to match my command line results with IMagick code

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
flashape

trying to match my command line results with IMagick code

Post by flashape »

So, I have this command line that does exactly what I need, works perfectly (the actual values are being set in php):

Code: Select all

$cmd2 = 'composite -compose src-over '.$headFile.' -matte -background none -rotate '.$rot.' -geometry '.$w.'x'.$h.$geomX.$geomY.'  '.$ripPath .'/frame'.$i.'.jpg '.$outputDir.'/frame'.$i.'.jpg';
When trying to accomplish this with Imagick, it's close, but as far as I can tell, the rotation works differently. Here is what I am using:

Code: Select all

$head = new Imagick( 'temp/frame' . $i . '.png' );

$frame->readImage( 'temp/frame' . $i . '.png' );
 
$tmpHead = $head->clone();
   
$tmpHead->thumbnailImage( $w, $h );
      
$tmpHead->rotateImage( 'transparent', $rot );
      
$frame->compositeImage( $tmpHead, Imagick::COMPOSITE_OVER, $x, $y );

$frame->writeImage( 'output/frame'.$i.'.jpg' );
so what's happening is that if the rotation is greater than 0, the head is being composed funny, like distorted. Any idea how to match the output of the command line?
mkoppanen
Posts: 309
Joined: 2007-06-09T07:06:32-07:00

Re: trying to match my command line results with IMagick code

Post by mkoppanen »

Can I see resulting images from both the command-line operation and the imagick operation?
Mikko Koppanen
My blog: http://valokuva.org
flashape

Re: trying to match my command line results with IMagick code

Post by flashape »

Sure, here's a zip with two frames. As you can see, in the imagick one, the head is way off in size

http://www.visible-form.com/zips/imagick_test.zip
flashape

Re: trying to match my command line results with IMagick code

Post by flashape »

seems like rotating the image BEFORE thumbnailing it works a lot better, except that the script runs a lot slower now.
mkoppanen
Posts: 309
Joined: 2007-06-09T07:06:32-07:00

Re: trying to match my command line results with IMagick code

Post by mkoppanen »

I think the same happens with the command line version (rotate first).
Mikko Koppanen
My blog: http://valokuva.org
Post Reply