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 » 2017-12-19T22:43:07-07:00

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

Re: CommandException: 'gs' while trying to convert

Post by snibgo » 2017-12-20T01:25:16-07:00

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 » 2017-12-20T01:45:47-07:00

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 » 2017-12-25T22:31:07-07:00

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: 22450
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: CommandException: 'gs' while trying to convert

Post by fmw42 » 2017-12-25T23:54:22-07:00

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 » 2017-12-26T00:13:03-07:00

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: 22450
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: CommandException: 'gs' while trying to convert

Post by fmw42 » 2017-12-26T00:58:45-07:00

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 » 2017-12-26T02:25:49-07:00

Any idea to solve this problem?

snibgo
Posts: 9589
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: CommandException: 'gs' while trying to convert

Post by snibgo » 2017-12-26T06:50:04-07:00

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 » 2017-12-27T23:59:46-07:00

Thanks, i am trying to solve.

Post Reply