Page 1 of 1

composite and convert in a single command

Posted: 2009-10-04T07:20:55-07:00
by aberkl
Hi,

I have tried for hours and searched half the web but was not successful. Or maybe more likely I didn´t understand what I found...

I would like to combine two images with composite and then annotate a text with convert on top of the composition.

If I do it in two steps it works:

Code: Select all

composite -geometry +200+0 rose: logo: tempfile
convert tempfile -gravity south -annotate +0+20 "sometext" outfile_final
Needless to say this is pretty slow for hundreds of images since I write the tempfile and then re-open it in the second command...

I know it should be possible to have both operations in a single command without the need to use a "tempfile", but how?

Thanks in advance,
Andreas

Re: composite and convert in a single command

Posted: 2009-10-04T08:20:39-07:00
by Bonzo
You do not say how you are using the code.

Try this:

Code: Select all

composite -geometry +200+0 rose: logo: miff:- | convert -gravity south -annotate +0+20 "sometext" - outfile_final.png

Re: composite and convert in a single command

Posted: 2009-10-04T11:34:38-07:00
by fmw42
use convert to do the composite so you can have it in one command

convert logo: rose: -geometry +200+0 -composite -gravity south -annotate +0+20 "sometext" outfile


see http://www.imagemagick.org/Usage/compose/#compose

Re: composite and convert in a single command

Posted: 2009-10-04T22:56:26-07:00
by aberkl
Hi Bonzo, hi fmw42,

thanks for your hints. I tried Bonzo´s version and it works perfectly. Will do a test with the other version asap to find out which is faster.

Thanks again, Andreas

Re: composite and convert in a single command

Posted: 2009-10-05T05:59:11-07:00
by aberkl
H Bonzo, hi fmw42,

just did some speed tests, loop with 10 calls to both commands, results in seconds on my (pretty old) PC:

Bonzo´s code: 6 seconds:

Code: Select all

composite -geometry +200+0 rose: logo: miff:- | convert -gravity south -annotate +0+20 "sometext" - outfile_final.png
fmw42´s code: 3.5 seconds

Code: Select all

convert logo: rose: -geometry +200+0 -composite -gravity south -annotate +0+20 "sometext" outfile
Thanks for your support!
Best, Andreas

Re: composite and convert in a single command

Posted: 2009-10-05T12:42:31-07:00
by fmw42
the added time is to do the pipe | to a new convert. so you have to call convert twice in the first method. that adds time.