convert hangs on converting pdf to jpg
convert hangs on converting pdf to jpg
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?
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?
Re: convert hangs on converting pdf to jpg
Can you add a link to the PDF you are using? And did you install the latest version of GhostScript?
Re: convert hangs on converting pdf to jpg
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.
Just for kicks I tried other ImageMagick programs like mogrify, composite and montage and they all instantly get to 50% CPU usage and hang.
Re: convert hangs on converting pdf to jpg
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.
Re: convert hangs on converting pdf to jpg
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.
Re: convert hangs on converting pdf to jpg
I just tried using GhostScript to convert the PDF to a JPG and it worked just fine.
Re: convert hangs on converting pdf to jpg
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.
- 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
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""/>
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""/>
Re: convert hangs on converting pdf to jpg
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""/>
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""/>
- 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
Look fine to me. I guess the best thing is to send an image to dlemstra.
Re: convert hangs on converting pdf to jpg
Thank you for sending me the pdf file. The problem seems to be somewhere in GhostScript. It hangs with the following command:
I can reproduce this on the command line. I think you should file a bug report here: http://bugs.ghostscript.com/
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"
Re: convert hangs on converting pdf to jpg
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.
Re: convert hangs on converting pdf to jpg
Just FYI, if I take out this parameter and change the output device to png16m it works fine.
Here is the command that worked for me.
Code: Select all
-dGraphicsAlphaBits=4
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"
Re: convert hangs on converting pdf to jpg
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.
Re: convert hangs on converting pdf to jpg
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.