ImageMagick: convert quits after some pages

16

5

I try to convert some jpgs into one single pdf in using convert.

convert *.jpg new.pdf

But convert does quit after 18 pages. The output then is ok but not complete.

convert-im6.q16: DistributedPixelCache '127.0.0.1' @ error/distribute-cache.c/ConnectPixelCacheServer/244.
convert-im6.q16: cache resources exhausted `094708.JPG' @ error/cache.c/OpenPixelCache/3945.
...

I tried some limit settings but without success. If I try other jpgs then it is the same result.

Any ideas? I have plenty of free memory.

Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 
...
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png tiff wmf x xml zlib

chris01

Posted 2017-02-14T12:59:32.897

Reputation: 261

It looks like a newer version is available so you might just check the site and download and update if applicable. If it's a bug, it may be patched in the newer version. Something to consider perhaps at least. https://www.imagemagick.org/script/download.php

– Pimp Juice IT – 2017-02-14T13:13:22.903

2

Check out the -limit switch.... https://www.imagemagick.org/script/command-line-options.php#limit You can likely -limit memory <#> with this switch in case it's your machine running out of memory to process all the files. Otherwise, try to merge less than you are in smaller batches and see if that makes any difference. So if there are a hundred, copy 25 to a test folder and see if the same happens with 25 for example. Perhaps you can merge them all in smaller chunk then at the end merge the PDF documents that were created together. I've always used PDFTK for PDF file merges though.

– Pimp Juice IT – 2017-02-14T13:20:55.350

Answers

24

Try to add the following option to increase the cache

convert -limit memory 1GiB -limit disk 1GiB *.jpg new.pdf

If it doesn't work set the limits into the image magic configuration file /etc/ImageMagick-6/policy.xml

<policy domain="resource" name="memory" value="256MiB"/>
<policy domain="resource" name="disk" value="1GiB"/>

to

<policy domain="resource" name="memory" value="3GB"/>
<policy domain="resource" name="disk" value="2GB"/>

and try it again

Philippe Gachoud

Posted 2017-02-14T12:59:32.897

Reputation: 545

The change to policy.xml has the same effect as the command line options but is permanent. So it's almost always a good idea, because it's "write and forget". – tanius – 2018-11-09T22:47:44.403

5

@tanius editing the xml worked, but CLI options didn't. Ubuntu 18.10, ImageMagick 6.9.10-8, with these images: https://github.com/cirosantilli/media/blob/master/opengl-rotating-triangle.zip?raw=true

– Ciro Santilli 新疆改造中心法轮功六四事件 – 2018-12-23T16:50:15.780

Same as Ciro reports, cli did not work, xml did. Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 on Debian 9. – Luis Antolín Cano – 2019-05-23T11:49:18.957

https://github.com/ImageMagick/ImageMagick/issues/396#issuecomment-285024219 says that the security policy in the XML will override command line options. – jamadagni – 2019-08-29T06:58:06.237