Page 1 of 1

.png to .pdf conversion is failing with memory allocation error.

Posted: 2019-08-21T01:37:10-07:00
by RAmbika
Hi Team,

When we try to convert a particular .png file of size 35MB is giving the below error:

convert.exe: memory allocation failed `001_25.png[0]' @ error/cache.c/AcquireCacheNexusPixels/4983.
Caught exception: Magick: Strip/tile too large for JPEG. `JPEGPreEncode' @ error

We are using the convert.exe command like this:
convert.exe 001_25.png -resize ! -density "200" result.pdf

ImageMagick version we are using : 7.0.8.12

Please find the input image file at the below path.

https://drive.google.com/file/d/12jsITN ... sp=sharing

Could you please let us know how can we resolve this issue?

Thanks,
Ambika
(case - 25048669)

Re: .png to .pdf conversion is failing with memory allocation error.

Posted: 2019-08-21T05:16:08-07:00
by snibgo
Your "-resize !" is not documented syntax. What do you want IM to do with it?

For v7, I suggest you use "magick", not "convert" or "magick convert".

Your input is large, 315 M pixels.

For me, IM v7.0.7.-28 on a Windows 12 GB laptop, the command ...

Code: Select all

magick 001_25.png -density 200 x.pdf
... works fine, using a 2.5 GB temporary file for the pixel cache because I don't have enough free memory. But Adobe Acrobat Reader says:
The dimensions of this page are out-of-range. Page content might be truncated.
Check your temporary area (/tmp on Unix or %TEMP% on Windows) has enough free space.

You might try limiting memory usage so the pixel cache is forced to disk:

Code: Select all

magick 001_25.png -limit memory 10MB -limit map 10MB x.pdf

Re: .png to .pdf conversion is failing with memory allocation error.

Posted: 2019-08-21T08:54:05-07:00
by fmw42
-resize needs a new size value. You cannot just use ! by itself. See https://imagemagick.org/script/command- ... p#geometry

Re: .png to .pdf conversion is failing with memory allocation error.

Posted: 2019-08-23T05:26:34-07:00
by RAmbika
Hi,

We tried on the Windows 16 GB machine by freeing up the temporary area with the suggested commands:
1. magick 001_25.png -density 200 x.pdf
2. magick 001_25.png -limit memory 10MB -limit map 10MB x.pdf

There is 10 GB free memory but, still we get the same error(magick: memory allocation failed `001_25.png[0]' @ error/cache.c/AcquireCacheNexusPixels/4983).

Thanks,
Ambika

Re: .png to .pdf conversion is failing with memory allocation error.

Posted: 2019-08-27T04:16:41-07:00
by RAmbika
Hi,

Could you please help us to resolve this issue?

Thanks,
Ambika

Re: .png to .pdf conversion is failing with memory allocation error.

Posted: 2019-08-27T04:43:41-07:00
by magick
The conversion worked for us without complaint. We're using the latest ImageMagick release, 7.0.8-62. Download this release and let us know if the problem persists.

Re: .png to .pdf conversion is failing with memory allocation error.

Posted: 2019-08-30T06:26:36-07:00
by RAmbika
Hi,

If I directly install the ImageMagick exe(ImageMagick-7.0.8-62-Q8-x86-dll.exe) and try the conversion it is working fine.
But, by following the steps mentioned here https://imagemagick.org/script/install- ... hp#windows to extract the binaries and then if we try the conversion using the generated exe, then the conversion is not working.

could you please help us to resolve this issue in this scenario?

thanks,
Ambika

Re: .png to .pdf conversion is failing with memory allocation error.

Posted: 2019-08-30T08:08:36-07:00
by snibgo
RAmbika wrote:...then the conversion is not working.
Have you checked the build with simpler commands like "magick rose: r.png"?
What happens with your command? Any error messages? What is the text output if you insert "-verbose" as the first option?

Re: .png to .pdf conversion is failing with memory allocation error.

Posted: 2019-09-04T05:59:59-07:00
by RAmbika
Hi,

The command "magick rose: r.png" works fine with the build.

With command "magick 001_25.png -density 200 x.pdf" it is throwing the error "magick: memory allocation failed `001_25.png[0]' @ error/cache.c/AcquireCacheNexusPixels/4987)."

By inserting "-verbose" as first option in our command like "magick -verbose 001_25.png -density 200 x.pdf" we get the following:
001_25.png PNG 3392x93021 3392x93021+0+0 8-bit Gray 256c 35.3529MiB 33.166u 0:34.402
001_25.png=>x.pdf PNG 3392x93021 3392x93021+0+0 8-bit Grayscale Gray 256c 35.3529MiB 31.122u 0:31.155
magick: pixel cache allocation failed `001_25.png[0]' @ error/cache.c/AcquireCacheNexusPixels/4987.

Please have a look into this and let us know the way to get the successful conversion.

Thanks,
Ambika

Re: .png to .pdf conversion is failing with memory allocation error.

Posted: 2019-09-04T07:04:29-07:00
by snibgo
Sorry, I don't know what else to suggest.

Re: .png to .pdf conversion is failing with memory allocation error.

Posted: 2019-09-08T06:45:00-07:00
by magick
Try this command:

Code: Select all

magick -limit memory 1GiB -limit map 2GiB -define registry:temporary-path=./ 001_25.png -density 200 x.pdf
Does that command work for you?

Re: .png to .pdf conversion is failing with memory allocation error.

Posted: 2019-09-09T04:53:06-07:00
by RAmbika

Code: Select all

magick -limit memory 1GiB -limit map 2GiB -define registry:temporary-path=./ 001_25.png -density 200 x.pdf
this command did not work for us


It looks like regression issue. It worked for us with the 6.9.1-2 version of ImageMagick.
After upgrading to 7.0.7.21 and later this particular .png file works no more for us with 32-bit binaries.

Re: .png to .pdf conversion is failing with memory allocation error.

Posted: 2019-09-09T12:04:54-07:00
by magick
The command works flawlessly for us. We're using ImageMagick 7.0.8-64, the latest release under Linux. We'll try under Windows when we get a chance.

Re: .png to .pdf conversion is failing with memory allocation error.

Posted: 2019-09-25T01:57:21-07:00
by RAmbika
Did you get a chance to check under windows environment?