montage resolution limit

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
samster34
Posts: 5
Joined: 2012-07-08T14:58:21-07:00
Authentication code: 13

montage resolution limit

Post by samster34 »

I'm trying to use montage to tile quite a bunch of images.

First, I need to tile 196 sets of 391 256x256 images, each set looks like this:

Code: Select all

montage -geometry +0+0 9-[0-390]-0.tga -tile 391x1 9-0.tga
Then:

Code: Select all

montage -geometry +0+0 9-[0-195].tga -tile 1x196 9.tga

However, each assembled row would have a width of 100,096, which exceeds some limit. If I try this with jpeg images, the error message states that 65,500 is the maximum supported width/height, with tga files it just says the limit has been exceeded.

I'm on linux, Ubuntu 12.04 64bit to be exact, I've tried both a binary release installed through apt-get, and compiling it from source with --with-quantum-depth=8, 16, and 32. It seems like the limit I'm hitting is not in imagemagick itself, but rather the encoders?

Surely there must be a way around this limit, I never hit it when I was using montage on windows with equally large output images
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: montage resolution limit

Post by fmw42 »

It could be a memory limitation?? see http://www.imagemagick.org/Usage/files/#massive if montage allows those arguments
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: montage resolution limit

Post by anthony »

samster34 wrote:I'm trying to use montage to tile quite a bunch of images.

First, I need to tile 196 sets of 391 256x256 images, each set looks like this:

Code: Select all

montage -geometry +0+0 9-[0-390]-0.tga -tile 391x1 9-0.tga
WARNING: in UNIX Bash the '[0-390]' does NOT mean a number from 0 to 390, it means a single character of either '0' '-' '3' '9' ('0' is uselessly repeated)

If you want to read in all 391 files, 0 to 390, then you would need to use the special IM read modifier...
'9-%d-0.tga[0-390]'
Make sure you include the quotes so that 'BASH' does not try to interpret the square brackets.

See IM Examples, Image File Handling, Reading Images
http://www.imagemagick.org/Usage/files/#read
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
samster34
Posts: 5
Joined: 2012-07-08T14:58:21-07:00
Authentication code: 13

Re: montage resolution limit

Post by samster34 »

anthony: thanks, that helps.

fmw42: I don't see how it could be a memory limitation, montage -list resource lists 33.6GiB area, 15.6GiB memory and 31.3GiB map limits.

one complete row of 256x256 tiles would take about 73 MiB memory, I really don't see how that could hit any sort of limit, I have 16GiB RAM and about 15 of that are available.

Doing some experimenting, if I merge tiles 9-0-0.tga through 9-126-0.tga as 127x1, I get the expected output.
If I merge 0 through 127 as 128x1 however, the output has the correct dimensions but is entirely black...and 0 through 255 as 256x1 finally triggers the "exceeds width or height limit" error (that's at 65536 pixels width, 36 over the limit the jpeg error message stated)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: montage resolution limit

Post by anthony »

samster34 wrote:I'm trying to use montage to tile quite a bunch of images.

First, I need to tile 196 sets of 391 256x256 images, each set looks like this:

Code: Select all

montage -geometry +0+0 9-[0-390]-0.tga -tile 391x1 9-0.tga
Now we have syntax out of the way. Lets look at technique.

Are you wanting simply append the images? No resize, no spacing?

If so try something a little more direct with...

Code: Select all

  convert '9-%d-0.tga[0-391]' -append 9-0.tga
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
samster34
Posts: 5
Joined: 2012-07-08T14:58:21-07:00
Authentication code: 13

Re: montage resolution limit

Post by samster34 »

Code: Select all

convert: width or height exceeds limit `9-0.tga' @ error/tga.c/WriteTGAImage/702.
still the same issue
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: montage resolution limit

Post by anthony »

May be a limit for the TGA image file format.

Just how big are your 391 images?

(Sorry change -append to +append for horizontal appending)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
samster34
Posts: 5
Joined: 2012-07-08T14:58:21-07:00
Authentication code: 13

Re: montage resolution limit

Post by samster34 »

256x256 pixels for each image, except the last one which is 160x256

and the 196th row is 256x80, except for the last one which is 160x80, so the total combined image would be 100,000x50,000

Ultimately I want to resample the final image to something like 65536x32768, but since it's not a neat scaling factor like 1/4 the resolution, I can't just downsample the individual tiles before merging...

Is it possible to convert +append, and resample before saving to 65536x256 (and 65536x80 for the last row), then -append all the saved rows into one 65536x50000 image and resample to 65536x32768?

however, that'd still be 36 pixels too wide for some reason...

if this is a built in size limitation in both jpeg and tga, what other format should I use? I don't want or need compression.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: montage resolution limit

Post by anthony »

samster34 wrote:256x256 pixels for each image, except the last one which is 160x256

and the 196th row is 256x80, except for the last one which is 160x80, so the total combined image would be 100,000x50,000
Your -tile option in the montage is placing all images on a single line, not multiple lines. So your final image height does not make sense.

Oh I see the 391 images is just one row only. 256x390+160 => 100,000

Note resize is a two pass resize operator. So why not try seperating the two resize passes..
That is append all the images in one row, then just resize horizontally only. (you will need a '!' flag to the resize.

After you append all rows, you can then resize the whole image vertically to produce the final image.

That should be less memory hungry than doing all the image in one go, which is what I assume you are trying to avoid.

Also try saving intermediate images in say MPC (memory dump). It is fast to save (no formating) and fast to reload (just disk swap into memory) But only works with the same IM compilation.
http://www.imagemagick.org/Usage/files/#mpc
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
samster34
Posts: 5
Joined: 2012-07-08T14:58:21-07:00
Authentication code: 13

Re: montage resolution limit

Post by samster34 »

Thanks, saving to that intermediate format should take care of most of these issues!

The question remains though, what format should I use for the final resized output?
TGA and JPEG both seem to have the same limit of 65500, and BMP files turn out empty when trying to save ones wider than that as well...
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: montage resolution limit

Post by anthony »

JPEG will degrade the image, it is part of that format.

I am not certain what image formats can handle that size. But weren;t you talking about resizing the images Something about a factor of 4?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply