13

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?

0

2 Answers 2

19

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.

4
  • 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
    Commented Nov 11, 2014 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. Commented Nov 11, 2014 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 (i.imgur.com/Nbm9z8w.png) has a bit_depth of 8?
    – Selphiron
    Commented Nov 11, 2014 at 15:49
  • You'll be just fine - you only have 4 colours :-) Check it yourself like this identify -verbose image.png Commented Nov 11, 2014 at 19:18
10

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 ... 
3
  • I also had the Idea with the rows but I still had the same error. I will try -debug cache and -limit memory , thanks!
    – Selphiron
    Commented Nov 10, 2014 at 10:56
  • So I had to combine yours and Glenn Randers-Pehrsons answers to solve my problem. Which answer do I have to accept?
    – Selphiron
    Commented Nov 11, 2014 at 15:18
  • 3
    Go with Glenn's - I'm sure he'll be pleased to get his 2,000 points! Commented Nov 11, 2014 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.