Is it possible to merge multiple 'montage' 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
MrChristo
Posts: 1
Joined: 2015-04-19T01:59:29-07:00
Authentication code: 6789

Is it possible to merge multiple 'montage' command ?

Post by MrChristo »

Hello everybody
I have a script that takes 4 pictures and duplicate them to have 8 small pictures in one.

Here is what i expect : http://img11.hostingpics.net/pics/831624stack.png

I have a code that works well but it needs to save multiple temporary images. So I was looking if I could merge those command to have only one image saving. That would help to make the script faster.

Code: Select all

 //Make image smaller
    convert /home/pi/images/*.png -resize 487x296 -flop  -set filename:f "/home/pi/imagesResized/%t%p" '%[filename:f].png

//Make one col off 4 images
    montage /home/pi/imagesResized/*.png -tile 1x4 -geometry +0+15 -background none  /home/pi/line.png

//Duplicate to two cols
    montage /home/pi/line.png /home/pi/line.png -tile 2x1  -geometry +45+0 -background none /home/pi/photos.png

//Add the background
    suffix=$(date +%H%M%S)
    montage /home/pi/photos.png -geometry +20+247 -texture /home/pi/data/background_photo.png /home/pi/photo_${suffix}.jpg

Is that a good way to do it ?
Thanks everybody !
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Is it possible to merge multiple 'montage' command ?

Post by fmw42 »

You did not provide your version of IM nor platform. But I assume you are on Unix. So the only way to combine these commands that I am aware is to pipe them. IM does not support combining directly between convert and montage. But you can combine successive convert commands by using parenthesis processing.
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: Is it possible to merge multiple 'montage' command ?

Post by pipitas »

MrChristo wrote:Hello everybody
I have a script that takes 4 pictures and duplicate them to have 8 small pictures in one.

Here is what i expect : http://img11.hostingpics.net/pics/831624stack.png

[....]


Is that a good way to do it ?
Thanks everybody !
You asked here too,

http://stackoverflow.com/q/29727816/359307

but so far didn't even check back for an answer! (There are 3 now, even including benchmark data...)
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: Is it possible to merge multiple 'montage' command ?

Post by pipitas »

fmw42 wrote:IM does not support combining directly between convert and montage.
This answer does so, successfully,...
...and it is getting the fastest benchmark result (a saving of ~28% in time when compared to MrChristo's 4 single commands).

But maybe with "combining" you didn't mean to include piping?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Is it possible to merge multiple 'montage' command ?

Post by fmw42 »

This answer does so, successfully,...
It still involves piping. There is no way I know to avoid the pipe and not write temp files to disk. Perhaps some one else has a better way.
Post Reply