CommandException: 'gs' while trying to convert

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
joshanashakya
Posts: 6
Joined: 2017-12-19T22:26:52-07:00
Authentication code: 1152

CommandException: 'gs' while trying to convert

Post by joshanashakya »

Hello everyone,

I tried to convert pdf to image but got this error message:

org.im4java.core.CommandException: 'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r144x144' '-sOutputFile=/var/folders/n9/ykgrcs6n60vd805mr6mrnv0h0000gn/T/magick-1294bYHYFtaChjfp%d' '-f/var/folders/n9/ykgrcs6n60vd805mr6mrnv0h0000gn/T/magick-1294EQono57J3WJo' '-f/var/folders/n9/ykgrcs6n60vd805mr6mrnv0h0000gn/T/magick-1294yqfBAFSG3Vzl'

I am trying to figure out the problem. Any idea what's the problem?

Thank you
Joshana Shakya
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: CommandException: 'gs' while trying to convert

Post by snibgo »

It generally helps if you say what version IM you use, on what platform.

But the answer is that IM delegates reading PDF files to Ghostscript. If you haven't installed Ghostscript, that's the problem.
snibgo's IM pages: im.snibgo.com
joshanashakya
Posts: 6
Joined: 2017-12-19T22:26:52-07:00
Authentication code: 1152

Re: CommandException: 'gs' while trying to convert

Post by joshanashakya »

I have installed ghostscript and it worked.
joshanashakya
Posts: 6
Joined: 2017-12-19T22:26:52-07:00
Authentication code: 1152

Re: CommandException: 'gs' while trying to convert

Post by joshanashakya »

Though I have been able to convert pdf to image after installation of ghostscript, I got the error message:

org.im4java.core.CommandException: org.im4java.core.CommandException: "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r144x144" "-sOutputFile=/tmp/magick-469rWKTCxMHK7kT%d" "-f/tmp/magick-469jHztSM3q9nR9" "-f/tmp/magick-469_QtQgeUXyLnq"

trying to convert 1K pdf to image at once. Any idea how to solve this problem?

I am using 6.8.9 version and java platform.

Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: CommandException: 'gs' while trying to convert

Post by fmw42 »

What was your exact command line?
joshanashakya
Posts: 6
Joined: 2017-12-19T22:26:52-07:00
Authentication code: 1152

Re: CommandException: 'gs' while trying to convert

Post by joshanashakya »

I used run() method of org.im4java.core.ConvertCmd class in java 8 platform. And the exception occurred infrequently while converting those pdfs of size 44.6MB.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: CommandException: 'gs' while trying to convert

Post by fmw42 »

Perhaps you are running out of memory or tmp space.
joshanashakya
Posts: 6
Joined: 2017-12-19T22:26:52-07:00
Authentication code: 1152

Re: CommandException: 'gs' while trying to convert

Post by joshanashakya »

Any idea to solve this problem?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: CommandException: 'gs' while trying to convert

Post by snibgo »

joshanashakya wrote:Any idea to solve this problem?
First, find the cause of the problem. 45MB is large for a PDF, so I suspect as Fred says, you ran out of memory or /tmp. How many pages in the PDF, how many pixels per page? At 8 bytes per pixel, how much memory does that take?
snibgo's IM pages: im.snibgo.com
joshanashakya
Posts: 6
Joined: 2017-12-19T22:26:52-07:00
Authentication code: 1152

Re: CommandException: 'gs' while trying to convert

Post by joshanashakya »

Thanks, i am trying to solve.
Post Reply