composite and convert in a single command

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
aberkl
Posts: 45
Joined: 2009-06-29T03:53:05-07:00
Authentication code: 8675309
Location: Germany/Munich

composite and convert in a single command

Post 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
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: composite and convert in a single command

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: composite and convert in a single command

Post 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
aberkl
Posts: 45
Joined: 2009-06-29T03:53:05-07:00
Authentication code: 8675309
Location: Germany/Munich

Re: composite and convert in a single command

Post 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
aberkl
Posts: 45
Joined: 2009-06-29T03:53:05-07:00
Authentication code: 8675309
Location: Germany/Munich

Re: composite and convert in a single command

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: composite and convert in a single command

Post 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.
Post Reply