Page 1 of 1

Combining crop and compose in one line.

Posted: 2009-05-30T17:10:26-07:00
by mountainman
I've created a bash script to copy skinnier and skinnier segments from the center of one image, and paste them over another image. This creates a "barn door wipe" effect for use in a video. The relavant portion of the script is:

Code: Select all

convert $startimage  -gravity center  -crop $percent%x100%  temp.png 
composite -gravity center temp.png $endimage -quality $qual frame$counter$ext
This works as I had hoped. However, since this is inside a loop the fact that it first writes the cropped image to a temp file (a png image) each time is inefficient. What I'd like to do is combine this all into one statement and skip writing the temp file. In looking at the documentation, I found the usage example for composites. However, in the example given the image created with the convert statement is used as the background, and I want this to be the foreground. I've played around with several different ways I thought might work with this, but so far no luck. Can anyone here suggest a way to do this? Thanks!

Re: Combining crop and compose in one line.

Posted: 2009-05-30T17:24:18-07:00
by el_supremo
I think this will do it:

Code: Select all

convert -gravity center $endimage \( $startimage  -gravity center  -crop $percent%x100% +repage \) -composite -quality $qual frame$counter$ext
Note that when compositing with "convert" the two input files are specified in the opposite order than what the "composite" program requires.

Pete

Re: Combining crop and compose in one line.

Posted: 2009-05-30T18:02:00-07:00
by mountainman
Perfect! Thanks!