single convert vs three convert - same result - same performance?

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
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

single convert vs three convert - same result - same performance?

Post by agriz »

Code: Select all

convert image1.png [some process] image2.png
convert image3.png [some process] image4.png

convert image2.png -composite over image4.png
It uses three convert statement. If we write single convert for the above code, will both kind of codes require the same resource?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: single convert vs three convert - same result - same performance?

Post by snibgo »

Your second command is pointless, as image4.png will be overwritten (ignoring the possibility of multiple outputs).
snibgo's IM pages: im.snibgo.com
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: single convert vs three convert - same result - same performance?

Post by agriz »

Lets assume this.

Code: Select all

convert image1.png [some process] image2.png
convert image3.png [some process] image4.png

convert image2.png index4.png -composite over image5.png
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: single convert vs three convert - same result - same performance?

Post by agriz »

Please tell how the performance varies for a output, which is written in multiple convert against single convert
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: single convert vs three convert - same result - same performance?

Post by snibgo »

If you combine this into a single "convert image1.png image3.png {do_something} image5.png", you save:
- two invocations of the program
- one write to image2.png
- one write to image4.png
- one read of image2.png
- one read of image4.png
snibgo's IM pages: im.snibgo.com
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: single convert vs three convert - same result - same performance?

Post by agriz »

So single convert is always better?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: single convert vs three convert - same result - same performance?

Post by fmw42 »

It is faster, saves write times, and should produce the exact same result provide you do not save intermediates in lossy compression such as jpg in your original commands.
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: single convert vs three convert - same result - same performance?

Post by agriz »

Sir,

Code: Select all

convert -size 500x500 xc:none ( image.png -resize 100x100 ) -gravity center -compose Dst_Over -composite ( image2.png -resize 200x200 -gravity center -extend 200x200 ) -gravity center -compose Dst_Over -composite output.png
not working.

Code: Select all


convert -size 500x500 xc:none ( image.png -resize 100x100 ) -gravity center -compose Dst_Over -composite ( image2.png -resize 200x200 ) -gravity center -compose Dst_Over -composite output.png

working. Why the above one is not working?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: single convert vs three convert - same result - same performance?

Post by snibgo »

agiz wrote:-extend 200x200
What is the error message? "-extend" is not a valid operation. Perhaps you intended "-extent".
snibgo's IM pages: im.snibgo.com
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: single convert vs three convert - same result - same performance?

Post by agriz »

it was -extent. I wrongly typed here.

There is no error message, The image (image2) just becomes white in the output.
If i swap and add -extent to image1 again image1 becomes white and image2 works. If i remove -extent it works good.
To use extent, do i need -gravity center?

-gravity center cause the trouble i guess.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: single convert vs three convert - same result - same performance?

Post by snibgo »

"-extent" is sensitive to the "-compose" setting. Do you really want Dst_Over for extent?
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: single convert vs three convert - same result - same performance?

Post by fmw42 »

Put -compose over before -extent.
Post Reply