how to use just one IM call?

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
papoola
Posts: 10
Joined: 2010-07-16T08:25:16-07:00
Authentication code: 8675308

how to use just one IM call?

Post by papoola »

Hi everyone,, I am really thankful to be able to use ImageMagick in my software to render files.
Currently I have created template files which contain reference to images + render settings. Depending on arguments mentioned in these template files software will call IM convert.exe several times. These call are more or less like these:

Code: Select all

// input images
convert.exe "xxxxx1.jpg" .....  "xxxxx1.miff"
convert.exe "xxxxx2.jpg" .....  "xxxxx2.miff"
convert.exe "xxxxx3.jpg" .....  "xxxxx3.miff"
// output image
convert.exe xc:white -resize ?x? -draw "image Over ?,? 0,0 'xxxxx1.miff'" -draw "image Over ?,? 0,0 'xxxxx2.miff'" -draw "image Over ?,? 0,0 'xxxxx3.miff'" -quality 100 "output.jpg"
As you can see with this approach I render input images as seperate .miff files and then combine them together at last call by using -draw image.
I am wondering if there is a way to this in one IM convert call and having following things in mind:
  • I still should be able to resize/rotate/... all input images( "xxxxx1.jpg"/ "xxxxx2.jpg"/ "xxxxx3.jpg"/...)
  • input items could be placed at desired position in "output.jpg"
ProfessorJerk

Re: how to use just one IM call?

Post by ProfessorJerk »

Well for starters you can combine all your conversions from to miffs using the frame number replacement syntax

convert.exe "xxxx%03d.jpg"[1-3] ..... "xxxx%03d.miff"
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: how to use just one IM call?

Post by el_supremo »

If you know you will have, for example, three input images then try structuring a command like this:

Code: Select all

convert.exe -size ?x? xc:white ( "xxxxx1.jpg" .....  ) -geometry +?+? -composite ( "xxxxx2.jpg" .....  ) -geometry +?+? -composite  ( "xxxxx3.jpg" .....  ) -geometry +?+? -composite -quality 100 "output.jpg"
I've changed "xc:white -resize ?x?" to "-size ?x? xc:white" which might perform better. Each of the input images is processed (rotated etc.) within a pair of parentheses.
If you have a varying number of input images perhaps you can script this so that you build up a command and then execute it.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: how to use just one IM call?

Post by anthony »

el_supremo wrote:If you know you will have, for example, three input images then try structuring a command like this:

Code: Select all

convert.exe -size ?x? xc:white ( "xxxxx1.jpg" .....  ) -geometry +?+? -composite ( "xxxxx2.jpg" .....  ) -geometry +?+? -composite  ( "xxxxx3.jpg" .....  ) -geometry +?+? -composite -quality 100 "output.jpg"
I've changed "xc:white -resize ?x?" to "-size ?x? xc:white" which might perform better. Each of the input images is processed (rotated etc.) within a pair of parentheses.
If you have a varying number of input images perhaps you can script this so that you build up a command and then execute it.

Pete
I would use some form of line breaks to make the command simplier to follow

Code: Select all

convert.exe -size ?x? xc:white  \
        ( "xxxxx1.jpg" .....  ) -geometry +?+? -composite \
        ( "xxxxx2.jpg" .....  ) -geometry +?+? -composite  \
        ( "xxxxx3.jpg" .....  ) -geometry +?+? -composite \
        -quality 100 "output.jpg"
Also see IM Examples, Layered Images for other methods. Especially look at
Examples of Layering images
http://www.imagemagick.org/Usage/layers/#example

The second example uses a two stage approach. A loop to do the individual image processing, piping into a final image layering command.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
papoola
Posts: 10
Joined: 2010-07-16T08:25:16-07:00
Authentication code: 8675308

Re: how to use just one IM call?

Post by papoola »

Thank you guys.. :D I always assumed it might be possible to do that but didn't think that it would be that easy.
ProfessorJerk I still need to pass seperate parameters (like resize/rotate/...) for each image so I think approach suggested by el_supremo works way I want it. Anthony thank you for additional info. I will take a look at the two stage approach with pipline if parentheses approach wont work well for me.

8)
Post Reply