imagemagick get stuck while converting a pdf to jpg

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
ankurvas
Posts: 14
Joined: 2017-05-25T23:52:09-07:00
Authentication code: 1151

imagemagick get stuck while converting a pdf to jpg

Post 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
Last edited by ankurvas on 2018-09-18T23:10:34-07:00, edited 3 times in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: imagemagick get stuck while converting a pdf to jpg

Post 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
ankurvas
Posts: 14
Joined: 2017-05-25T23:52:09-07:00
Authentication code: 1151

Re: imagemagick get stuck while converting a pdf to jpg

Post 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
ankurvas
Posts: 14
Joined: 2017-05-25T23:52:09-07:00
Authentication code: 1151

Re: imagemagick get stuck while converting a pdf to jpg

Post 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.
ankurvas
Posts: 14
Joined: 2017-05-25T23:52:09-07:00
Authentication code: 1151

Re: imagemagick get stuck while converting a pdf to jpg

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: imagemagick get stuck while converting a pdf to jpg

Post 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.
snibgo's IM pages: im.snibgo.com
ankurvas
Posts: 14
Joined: 2017-05-25T23:52:09-07:00
Authentication code: 1151

Re: imagemagick get stuck while converting a pdf to jpg

Post 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?
ccd_jon
Posts: 1
Joined: 2018-09-20T02:54:47-07:00
Authentication code: 1152

Re: imagemagick get stuck while converting a pdf to jpg

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: imagemagick get stuck while converting a pdf to jpg

Post 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.
ankurvas
Posts: 14
Joined: 2017-05-25T23:52:09-07:00
Authentication code: 1151

Re: imagemagick get stuck while converting a pdf to jpg

Post by ankurvas »

Thanks a lot.
Post Reply