Page 1 of 1
montage use several gigabytes of RAM and swap
Posted: 2013-04-14T12:11:59-07:00
by contremaitre
Hi,
I have 400 pictures, and I would like to create 200 pictures, so 2 pictures into 1.
They all have the same resolution : 1333x1000
So my output pictures will be 1333x2000
The command is simple :
montage -geometry +0+0 -tile 1x2 *.jpg together.jpg
But it seems that this command read ALL images at once, instead of producing output one by one.
So it freeze my system by using all the available memory.
How can I solve this ?
Thanks.
Re: montage use several gigabytes of RAM and swap
Posted: 2013-04-14T12:16:10-07:00
by Bonzo
You could write some code to loop through the images and use +append
Re: montage use several gigabytes of RAM and swap
Posted: 2013-04-14T22:17:11-07:00
by anthony
Unless you do otherwise this reads in ALL the images at full size. Thus at some point you use a twice the memory needed (input images plus the output image result.
You can try to concatante images in smaller chunks. Say a row at a time then appead one row at a time together. In that case the last step still needs memory of the final image times 2!
On the other hand if you start with a full output sizes image, and 'compose' the rows onto that image, you only need memory of the large destaination image plus the small (row?) image being overlaid.
However IM "stream" command can vertically append images, and only needs in a single pixel row of pixels in memory at any time! So you would generate your rows, then stream append the rows together.
See.. Really Massive Image Handling
http://www.imagemagick.org/Usage/files/#massive
Re: montage use several gigabytes of RAM and swap
Posted: 2013-04-15T06:11:53-07:00
by contremaitre
Bonzo : Yes I could write a script, but I wanted to know if there is a solution with ImageMaick first.
anthony : My output picture is small : only 1333x2000 pixels. The issue is that IM creates the 200 output pictures at the same time and not one by one.
You say I need to handle large images but this is not the case, input and outputs are quite small.
Re: montage use several gigabytes of RAM and swap
Posted: 2013-04-15T06:52:14-07:00
by magick
Add -define jpeg:size=128x128 right after the montage keyword. It creates thumbnails as each image is read. Adjust the size as needed.
Re: montage use several gigabytes of RAM and swap
Posted: 2013-04-15T19:28:41-07:00
by anthony
montage always reads in all images at the same time --> LARGE memory use
mogrify only reads in one image at a time --> no image merging
neither will handles 2 images at a time
You will need to write a script to append 2 images at a time.
and that makes it a scripting problem rather than a imagemagick problem.
Hmmm, xargs can grab two images at a time, but you need to add those images in the middle of the command
But it is still posible to do..
Code: Select all
ls *.jpg | xargs -r -n2 sh -c 'convert "$0" "$1" +append ../output/"$0"'
Add an 'echo before the 'convert' to see what the above will do without actually doing it.
I do not recommend putting the output images in the same directory as the input images.