12

I have 100 PNG-files and each of them is 8250x4090 big. I need to append them with Imagemagick to one big PNG-file (82500 x 40900) so that I have 10 rows and 10 columns . I know how the code must look like but I get the errors: convert.exe: unable to extend cache

`C:\Row_345.png': No space left on device @ error/cache.c/OpenPixelCache/3689.
convert.exe: Memory allocation failed `C:\Row_345.png' @ error/png.c/WriteOnePNGImage/8725.

First question: How much space is needed (approximately)? I have 8 GB of Ram and 30 GB free SSD and it wasn't enough. The pictures have polygons and lines in up to 5 different colors. The biggest PNG is 300 KB) Second question: Is there a way how to make it more clever so that it won't use that much space?

Selphiron
  • 897
  • 1
  • 12
  • 30

2 Answers2

18

ImageMagick needs 8 bytes per pixel if you are using a Q16 build. A Q8 build only needs 4 bytes per pixel.

82500 * 40900 * 8 = about 27Gbytes 82500 * 40900 * 4 = about 13.5 Gbytes

The size of the PNG is irrelevant; ImageMagick stores them uncompressed.

Possibly ImageMagick is trying to hold two copies -- your 100 small images plus the large result. It may be that you'll have enough memory plus disk to run your conversion with ImageMagick-Q8.

Glenn Randers-Pehrson
  • 11,940
  • 3
  • 37
  • 61
  • Thanks. I combined your answer with Mark Setchells answer and it worked. but one question: Does Q8 has any downsides like lower quality or something like this? – Selphiron Nov 11 '14 at 15:20
  • As a general rule, Q8 will not be as accurate as Q16. But for particular operations, including "-append", it should be lossless if your original PNG files have bit_depth==8 or less. – Glenn Randers-Pehrson Nov 11 '14 at 15:36
  • I must admit that I don't know how to find out the bit_depth of a PNG file. Do you think that this (http://i.imgur.com/Nbm9z8w.png) has a bit_depth of 8? – Selphiron Nov 11 '14 at 15:49
  • You'll be just fine - you only have 4 colours :-) Check it yourself like this `identify -verbose image.png` – Mark Setchell Nov 11 '14 at 19:18
9

Try doing just a single row of 10 at a time, ten times - so you get 10 rows of 10. Then do row1 plus row2. Then rows 1&2 plus row 3.

convert 1.png 2.png 3.png ... +append row1.png
convert 11.png 12.png 13.png ... +append row2.png
...
convert 91.png 92.png 93.png ... +append row10.png

Then

convert row1.png row2.png -append row1and2.png

You can add -debug cache to your ImageMagick convert command like this:

convert -debug cache 1.png 2.png 3.png ... +append row1.png

You can also look at your resource settings as to what is available to ImageMagick like this:

identify -list resource

File         Area       Memory          Map         Disk    Thread         Time
-------------------------------------------------------------------------------
 768     1.0386GB    3.8692GiB    7.7384GiB    unlimited         4    unlimited

And increase resources like this:

convert -limit memory 32MiB ... 
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432