convert hangs on converting pdf to jpg

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
trevororr
Posts: 12
Joined: 2014-02-18T12:36:54-07:00
Authentication code: 6789

convert hangs on converting pdf to jpg

Post by trevororr »

I am running Windows Server 2008 using the latest version of ImageMagick. I am converting PDF's to JPG's and re-sizing them down for thumbnails. This works fine for almost all of the PDF's with the exception of a few. With these few when I try to convert them the convert process hangs and climbs to 50% of the CPU usage and never generates the JPG. I have looked at the properties of these few PDF's and compared them to the majority that work and cannot see any difference in the PDF properties.

Here is the command I am running.

"C:\Program Files\ImageMagick\convert.exe" "D:\files\filename.pdf" -resize 216x180 "D:\files\thumbnails\filename.jpg"

How do I go about troubling shooting this?
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: convert hangs on converting pdf to jpg

Post by dlemstra »

Can you add a link to the PDF you are using? And did you install the latest version of GhostScript?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
trevororr
Posts: 12
Joined: 2014-02-18T12:36:54-07:00
Authentication code: 6789

Re: convert hangs on converting pdf to jpg

Post by trevororr »

Yes I do have the latest version of GhostScript installed as well. The PDF's are password protected so I don't think my client would approve of me posting them publicly, they are not purchased PDF's but a username and password is required to download them.

Just for kicks I tried other ImageMagick programs like mogrify, composite and montage and they all instantly get to 50% CPU usage and hang.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: convert hangs on converting pdf to jpg

Post by dlemstra »

Did you specify the password for the pdf with -authenticate (http://www.imagemagick.org/script/comma ... thenticate)? The problem seems to be related to the PDF you are using so fixing your problem without it will be difficult. Can you ask your client if you can send it to me personally?
Last edited by dlemstra on 2014-02-18T14:44:54-07:00, edited 1 time in total.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
trevororr
Posts: 12
Joined: 2014-02-18T12:36:54-07:00
Authentication code: 6789

Re: convert hangs on converting pdf to jpg

Post by trevororr »

The PDF itself does not have a password, the username / password is on the website. Once authenticated you can download any / all of the PDF's.
trevororr
Posts: 12
Joined: 2014-02-18T12:36:54-07:00
Authentication code: 6789

Re: convert hangs on converting pdf to jpg

Post by trevororr »

I just tried using GhostScript to convert the PDF to a JPG and it worked just fine.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: convert hangs on converting pdf to jpg

Post by dlemstra »

Can you ask your client to give permission to send me one PDF file that is failing? With that PDF I can debug our code and figure out what is causing the problem. If this is possible then please send me a PM so we can share email addresses.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert hangs on converting pdf to jpg

Post by fmw42 »

What is your version of IM and also Ghostscript? Does your pdf have multiple pages with transparency?

Check your delegates.xml file for ps:alpha? Does it use sDevice=pngalpha or pnmraw?


<delegate decode="ps:alpha" stealth="True" command=""gsc" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "-f%s" "-f%s""/>
trevororr
Posts: 12
Joined: 2014-02-18T12:36:54-07:00
Authentication code: 6789

Re: convert hangs on converting pdf to jpg

Post by trevororr »

PDF is 1 page, not sure about the transparency though.

ImageMagick: 6.8.8
GhostScript: 9.10

Delegates:
<delegate decode="ps:alpha" stealth="True" command=""@PSDelegate@" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "-f%s" "-f%s""/>
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert hangs on converting pdf to jpg

Post by fmw42 »

Look fine to me. I guess the best thing is to send an image to dlemstra.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: convert hangs on converting pdf to jpg

Post by dlemstra »

Thank you for sending me the pdf file. The problem seems to be somewhere in GhostScript. It hangs with the following command:

Code: Select all

"C:\program Files (x86)/gs/gs9.10/bin/gswin32c.exe" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitT=2 "-sDEVICE=pamcmyk32" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72"  "-sOutputFile="output.png" "-finput.pdf"
I can reproduce this on the command line. I think you should file a bug report here: http://bugs.ghostscript.com/
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
trevororr
Posts: 12
Joined: 2014-02-18T12:36:54-07:00
Authentication code: 6789

Re: convert hangs on converting pdf to jpg

Post by trevororr »

Thanks for the help, I will contact GhostScript about this. It must be a specific command line parameter that is causing the hand because I am able to use GhostScript to convert the PDF to a JPG. Maybe I will play around with the parameters to find out which one is the issue.
trevororr
Posts: 12
Joined: 2014-02-18T12:36:54-07:00
Authentication code: 6789

Re: convert hangs on converting pdf to jpg

Post by trevororr »

Just FYI, if I take out this parameter and change the output device to png16m it works fine.

Code: Select all

-dGraphicsAlphaBits=4
Here is the command that worked for me.

Code: Select all

gswin32c.exe -q -dQUIET -dSAFER -dBATCH -dNOPAUSE  -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitT=2 -sDEVICE=png16m -dTextAlphaBits=4 "-r72x72" -sOutputFile="output.png" "-finput.pdf"
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: convert hangs on converting pdf to jpg

Post by dlemstra »

It looks like this bug has been fixed in GhostScript. I creates a correct file when I run the same command on Ubuntu with the latest source code from the git repository of GhostScript. To speak with the famous words of Homer: Mmm... beer.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
trevororr
Posts: 12
Joined: 2014-02-18T12:36:54-07:00
Authentication code: 6789

Re: convert hangs on converting pdf to jpg

Post by trevororr »

Great, I guess I will have to wait until they release the next windows version before I can use ImageMagick though, for now I am using GhostScript and another program to do what I need but I will go back to ImageMagick when I can.
Post Reply