Page 1 of 1
imagemagick get stuck while converting a pdf to jpg
Posted: 2018-09-18T22:29:26-07:00
by ankurvas
Hi All,
I am converting a pdf to jpg using the following command.
convert.exe -density 300 C:\Users\abc\Downloads\ghost_test\3.pdf -quality 100 C:\Users\abc\Downloads\ghost_test\test.jpg
Imagemagick gets stuck while processing it with very high CPU and Memory Usages.
Then, I tried to read the file with ghostscript also. It failed to read the file and the threw error.
This made me think that there could be something wrong with the pdf. I tried with other PDF's. It works fine for other input PDF's other than 2 PDF.
Regarding the PDF:
When I open the PDF in Adobe reader, it throws an error saying "the dimensions of this page are out of range page content might be truncated". But in adobe DC, it works fine and opening with chrome also, it opens fine.
I have raised a bug at the ghostscript as well.
But my question is how do I know that the problem is with the PDF and not with imageMagick.
How can I stop the high CPU and memory usage.
How can I stop imageMagick from getting stuck, once such input file is being sent for processing.
Sorry,
Version: ImageMagick 6.9.2-6 Q8 x64 2015-11-23
Platform Windows Server 2012
Link for the PDF
https://drive.google.com/drive/folders/ ... sp=sharing
Regards,
Ankur Vashishtha
Re: imagemagick get stuck while converting a pdf to jpg
Posted: 2018-09-18T22:35:17-07:00
by fmw42
When I open the PDF in Adobe reader, it throws an error saying "the dimensions of this page are out of range page content might be truncated".
Seems to me that this points to the PDF file. Post a link to it and the developers can check further.
___________________________
Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.
See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at
http://www.imagemagick.org/discourse-se ... f=1&t=9620
If using Imagemagick 7, then see
http://imagemagick.org/script/porting.php#cli
For novices, see
http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
Re: imagemagick get stuck while converting a pdf to jpg
Posted: 2018-09-18T23:09:47-07:00
by ankurvas
Updated the post with the relevant information.
Version: ImageMagick 6.9.2-6 Q8 x64 2015-11-23
Platform Windows Server 2012
Link for the PDF
https://drive.google.com/drive/folders/ ... sp=sharing
adding the command again
convert.exe -density 300 C:\Users\abc\Downloads\ghost_test\3.pdf -quality 100 C:\Users\abc\Downloads\ghost_test\test.jpg
Re: imagemagick get stuck while converting a pdf to jpg
Posted: 2018-09-18T23:21:17-07:00
by ankurvas
How can I limit the CPU usage here?
I can limit memory usage using -limit memory.
And the problem is it gets stuck at high CPU usage and doesn't even produce the rendition.
Re: imagemagick get stuck while converting a pdf to jpg
Posted: 2018-09-19T02:17:46-07:00
by ankurvas
I raised the issue with the ghostscript team as well. Ghostscript seems to be reading fine.
If we can give them the command ImageMagick is firing using ghostscript(used internally by ImageMagick), they can look further.
Re: imagemagick get stuck while converting a pdf to jpg
Posted: 2018-09-19T03:26:37-07:00
by snibgo
You haven't provided a working link to 3.pdf. (Hint: links don't contain three dots.)
"-verbose" should give the GS command.
Re: imagemagick get stuck while converting a pdf to jpg
Posted: 2018-09-19T20:02:03-07:00
by ankurvas
Adding the link again.
https://drive.google.com/open?id=1MoTrA ... M3tF8J-3sL
Somehow while copying it got shortened.
Thanks for the verbose part.
Is there any how I can make imagemagick not to use all the CPU?
Re: imagemagick get stuck while converting a pdf to jpg
Posted: 2018-09-20T03:23:53-07:00
by ccd_jon
Hi Guys,
We are currently experiencing the same issue with the PDF attached. It seems to get its self in a loop of creating temp files until it fills up the server's disk space. The PDF called 2.pdf you shared is also causing us the same issue.
Here is the link to our PDF in question
https://drive.google.com/file/d/1-3lMV6 ... sp=sharing
Version: ImageMagick 6.7.8-9 2016-06-16
Platform: CentOS 7
Re: imagemagick get stuck while converting a pdf to jpg
Posted: 2018-09-20T04:29:59-07:00
by magick
Your PDF has 244 pages. When converting, ImageMagick must first convert each page from PDF to an internal image format and then write it in the format you choose. Each page is stored in memory or on disk until all the pages are converted. See
https://imagemagick.org/script/architec ... tera-pixel for best practices when converting large image sequences. A less resource bound method to convert this PDF is one page at a time. You can write it in your favorite scripting language, here's an example in TCSH:
Code: Select all
#!/bin/tcsh
set i = 0
while ( $i < 244 )
echo "Page $i"
convert "image.pdf[$i]" image-$i.jpg
@ i ++
end
For PDF, you can also bypass ImageMagick and instead use Ghostscript.
Re: imagemagick get stuck while converting a pdf to jpg
Posted: 2018-09-21T01:37:32-07:00
by ankurvas
Thanks a lot.