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.
montage use several gigabytes of RAM and swap
-
- Posts: 6
- Joined: 2013-04-14T12:00:39-07:00
- Authentication code: 6789
Re: montage use several gigabytes of RAM and swap
You could write some code to loop through the images and use +append
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: montage use several gigabytes of RAM and swap
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
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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
-
- Posts: 6
- Joined: 2013-04-14T12:00:39-07:00
- Authentication code: 6789
Re: montage use several gigabytes of RAM and swap
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.
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
Add -define jpeg:size=128x128 right after the montage keyword. It creates thumbnails as each image is read. Adjust the size as needed.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: montage use several gigabytes of RAM and swap
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..
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.
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"'
I do not recommend putting the output images in the same directory as the input images.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/