I am trying to convert pdf file(which is scanned image with extension .pdf) into .jpg which is having multi pages using Python 3.6 with PythonMagick 0.9.13, ghostscript 0.6. All have been installed from PyCharm Interpreter Package.
OS-Windows10 64 bit
It was working fine for some time, but now its giving me an below error, i tried to find fix this by looking into suggestions given in all below links, nothing worked out. Can any one please help me to fix this? it would be great!!
Error with ImageMagick and Ghostscript converting from PDF
Imagemagick Convert PDF to JPEG: FailedToExecuteCommand `"gswin32c.exe" / PDFDelegateFailed
****************************Error Message********************
RuntimeError: Magick: PDFDelegateFailed `[ghostscript library 9.09] -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pamcmyk32" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -dUseCIEColor -dFirstPage=1 -dLastPage=1 "-sOutputFile=C:/Users/****/AppData/Local/Temp/magick-13092f9RE6HZSrtFU%d" "-fC:/Users/****/AppData/Local/Temp/magick-13092ks9r_NT8Xygw" "-fC:/Users/****/AppData/Local/Temp/magick-13092NNqfnGb-iNhM"': Unrecoverable error: invalidaccess in put
Operand stack:
true false --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- InputAttributes --nostringval-- --nostringval-- InputAttributes --nostringval--
# error/pdf.c/InvokePDFDelegate/274
Looks like you have an invalid PDF file. You also have an ancient version of Ghostscript, 9.09 is 5 years old and I'd start by trying the current version instead.
I'd also try just opening the PDF file with Ghostscript to see whether that works, if it doesn't then I'd need to have the original PDF file to say why.
One thing that is relevant, though you may not be able to change it, is; Don't use -dUseCIEColor.
Related
I am testing my file conversions on the test server and I got this error below. I tested the case on my local and it worked without a problem. On the server it gives me some trouble.
FailedToExecuteCommand `"gswin32c.exe" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g350x350 -dEPSCrop "-sOutputFile=C:/Windows/TEMP/magick-1520z9_ZtBD3O2dg%d" "-fC:/Windows/TEMP/magick-15203XcyD8hja0LJ" "-fC:/Windows/TEMP/magick-1520fnhOiV0JVLNJ"' (Le fichier spécifié est introuvable.) # error/delegate.c/ExternalDelegateCommand/475.convert:
Any help/tips would be greatly appreciated.
EDIT 2:
I also find a link where the imagemagick admin suggests to change the gs path in the delegates.xml. This solution looks promising but the delegate file has one entry for eps to ps conversions as below:
<delegate decode="eps" encode="ps" mode="bi" command=""#PSDelegate#" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -sDEVICE=ps2write "-sOutputFile=%o" -- "%i""/>
And I can't seem to find how imagemagick refers to the GS location. I added gs to the path variable and/or modified the delegates.xml with the location to fix this.
EDIT 3:
I have a error "no images defined" from the imagemagick convert command as below. Do I need to set up some permissions for gs because I don't find the temporary folders in the Temp directory.These seems to work magically on my local, but hesitates to function on the test server.
convert: Postscript delegate failed [ghostscript library 9.22] -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g350x350 -dEPSCrop "-sOutputFile=C:/Windows/TEMP/magick-110207SjtG6NIBllO%d" "-fC:/Windows/TEMP/magick-1102057mSI5SPZ919" "-fC:/Windows/TEMP/magick-11020HeIOX7qThedE" -c showpage: (null)' # error/ps.c/ReadPSImage/884.convert: no images definedD:\inetpub\IndependenceAWS\Conversion_DEV_DCHI\78\20190208-121606-797-QSAX2N0OVB\JPG\icam_logo_ToJPG.JPG' # error/convert.c/ConvertImageCommand/3300
For the first problem,
FailedToExecuteCommand `"gswin32c.exe"
Configure the path of the ghostscript bin folder on the system variables and/or configure the delegates.xml which can be found in the folder path C:\Program Files\ImageMagick-7.0.8-Q16
Modify the delegate as below:
delegate decode="eps" encode="ps" mode="bi" command=""C:\Program
Files\gs\gs9.26\bin\gswin64.exe#" -q -dQUIET -dSAFER -dBATCH
-dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -sDEVICE=ps2write "-sOutputFile=%o" -- "%i""
For the second problem where Imagemagick has problems to access the Temp folder of the C drive.
Add or uncomment the policy for the temporary file path as below
policy domain="resource" name="temporary-path"
value="D:/inetpub/IndependenceAWS/Conversion-Temp"/
Another edit in the same xml as below solves the problems and allows imagemagick to use the new folder for temporary conversions
policy domain="module" rights="read|write" pattern="{PS,PDF,XPS}"
A great thanks to all the people who have commented on my question and helped me solve these issues.
You need to install ghostscript.
You can download it here and install it and the error goes away.
For example, download the 64bit version, and double click it and go by its installation instructions. Then rerun your magick command, the FailedToExecuteCommand "gswin32c.exe" error will go away.
Note: as a comment mentioned: GS 9.26 has some bugs -- try downgrading to 9.23, 9.24 or 9.25. 3, using 9.27 produces neither errors nor output, but after changing to 9.24, all things are fine.
If anyone is having this issue with the MSYS2 build of ImageMagick, you need to install GhostScript through MSYS2: run either of:
on MSYS2 MinGW 64 bits: pacman -S mingw-w64-x86_64-ghostscript
on MSYS2 MinGW 32 bits: pacman -S mingw-w64-i686-ghostscript
Changed gs to full path.
Problem is here....
I know this is an old thread but I'd like to add my experience as it may help someone.
I was getting the same error as you, but for me the issue turned out to be not enough RAM.
This was running on a VM with not much RAM allocated, upgraded to 4GB and everything works great.
Have recently upgrade to imagemagick 7.0.8-14 and have lost the ability to convert a pptx file to a jpg(or any other file format). Was working version before upgrade. The below is the out put from running the convert cmd. Happens on all pptx that have been run against it.
imagemagick version: 7.0.8-14
ghostscript version: 9.07
centos 7
$ convert test.pptx[0] -thumbnail 650x650 -gravity center -extent 1500x1000 s1.jpg
\convert /tmp/magick-17292VzAbA_mfaxJX -> /tmp/magick-17292VzAbA_mfaxJX.pdf using filter : impress_pdf_Export
convert: PDFDelegateFailed `[ghostscript library 9.07] -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' -dFirstPage=1 -dLastPage=1 '-sOutputFile=/tmp/magick-17292RtJq2Z8iF5iK%d' '-f/tmp/magick-17292wskX7eyNic7t' '-f/tmp/magick-17292jHMWYZOpLjVd'': **** Warning: Dropping incorrect smooth shading object.
**** File did not complete the page properly and may be damaged.
Error: /rangecheck in --run--
Operand stack:
-1 --nostringval--
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1884 1 3 %oparray_pop 1883 1 3 %oparray_pop 1867 1 3 %oparray_pop --nostringval-- --nostringval-- 2 1 1 --nostringval-- %for_pos_int_continue --nostringval-- --nostringval-- false 1 %stopped_push --nostringval-- --nostringval--
Dictionary stack:
--dict:946/1684(ro)(G)-- --dict:1/20(G)-- --dict:82/200(L)-- --dict:82/200(L)-- --dict:109/127(ro)(G)-- --dict:292/300(ro)(G)-- --dict:27/32(L)-- --dict:6/8(L)-- --dict:21/40(L)--
Current allocation mode is local
GPL Ghostscript 9.07: Unrecoverable error, exit code 1
# error/pdf.c/InvokePDFDelegate/276.
convert: no images defined `s1.jpg' # error/convert.c/ConvertImageCommand/3288.
could you share your current version of Ghostscript by running the below command?
rpm -qa ghostscript
In case the version is anything above and including 9.07-31.el7_6.1, could you try to downgrade to 9.07-31 and report if it is fixing your problem? To downgrade to that version, run the below command:
yum downgrade ghostscript-9.07-31.el7
If this was fixing your problem, I would be more than happy if you could share the pptx file with me (if possible).
For more info, see:
https://bugzilla.redhat.com/show_bug.cgi?id=1657694
This problem should be fixed now with a release of ghostscript-9.07-31.el7_6.6.
Kind regards,
-Martin
I have PDFs that I need to convert to images. I have installed Imagemagick. I have a PDF named a.pdf that I can open (it is not corrupt) in the folder C:\Convert\
From the command line I am trying
C:\Convert>convert a.pdf a.jpg
And I am getting the error.
convert.exe: FailedToExecuteCommand `"gswin32c.exe" -q -dQUIET -dSAFER -dBATCH -
dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEV
ICE=pamcmyk32" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -dUseCIEColor
"-sOutputFile=C:/Users/MNALDO~1.COR/AppData/Local/Temp/magick-3704HYGOqqIK5rhI%d
" "-fC:/Users//MNALDO~1.COR/AppData/Local/Temp/magick-3704vK6aHo7Ju9WO" "-fC:/Use
rs//MNALDO~1.COR/AppData/Local/Temp/magick-3704GQSF9kK8WAw6"' (The system cannot
find the file specified.
) # error/delegate.c/ExternalDelegateCommand/480.
convert.exe: PDFDelegateFailed `The system cannot find the file specified.
' # error/pdf.c/ReadPDFImage/797.
convert.exe: no images defined `a.jpg' # error/convert.c/ConvertImageCommand/323
0.
UPDATE:
After the SO community helped me solve this issue I put together a little tool to batch convert images. Hope it helps somebody.
https://github.com/MattDolan/ImageConverter
You need to install Ghostscript in order to rasterize vector files (PDF, EPS, PS, etc.) with ImageMagick. IM will shell out to Ghostscript when doing these manipulations (you can see it if you use the -verbose tag in your IM invocation). You could also use Ghostscript by itself to rasterize vector files.
Since you actually have to install Ghostscript to do this, why not drop ImageMagick all-together? It just forwards the command to Ghostscript anyway, not adding any value, just taking way longer to process (and loading everything into RAM while its at it).
Install GhostScript and run the command:
gswin64c.exe -dNOPAUSE -sDEVICE=jpeg -r200 -dJPEGQ=60 -sOutputFile=foo-%03d.jpg foo.pdf -dBATCH
This is identical and faster than running:
convert -quality 60 -density 200 foo.pdf foo-%03d.jpg
It's in the docs now. https://github.com/dlemstra/Magick.NET/blob/main/docs/ConvertPDF.md
You need to install the latest version of GhostScript before you can convert a pdf using Magick.NET.
Make sure you only install the version of GhostScript with the same
platform. If you use the 64-bit version of Magick.NET you should also
install the 64-bit version of Ghostscript. You can use the 32-bit
version together with the 64-version but you will get a better
performance if you keep the platforms the same.
Here is a wrapper: https://archive.codeplex.com/?p=ghostscriptnet
I found that I had installed GhostScript, but GhostScript was not able to execute because it needed additional libraries. By typing "gs" on a command line, I was able to see what libraries were missing.
Install GhostScript GNU Affero General Public License from here.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am trying to use ghoshscript to convert a pdf in image.
The PDF is : http://www.coppernet.zm/MPLS.pdf
$ sudo docsplit images -o /tmp/previews -p 1-5 -s 150,750,1000 -f png MPLS.pdf
While reading gs_cidfm.ps:
Error: /rangecheck in --.dicttomark--
Operand stack:
(gs_cidfm.ps) 1 --nostringval-- 1 Arial --dict:4/4(G)--
Execution stack:
%interp_exit --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push --nostringval-- --nostringval-- --nostringval--
Dictionary stack:
--dict:956/1123(G)-- --dict:0/20(G)-- --dict:64/200(L)-- --dict:956/1123(G)-- --dict:8/14(G)-- --dict:1/1(G)--
Current allocation mode is global
Current file position is 4622
Unrecoverable error: undefined in .uninstallpagedevice
Operand stack:
gs_cidfm.ps 1 --nostringval-- 1 Arial --nostringval--
gm convert: "gs" "-q" "-dBATCH" "-dMaxBitmap=50000000" "-dNOPAUSE" "-sDEVICE=pnmraw" "- dTextAlphaBits=4" "-dGraphicsAlphaBits=4" "-r150x150" "-dFirstPage=1" "-dLastPage=1" " sOutputFile=/tmp/d20121211-1674-zs83qu/gme03xr0" "--" "/tmp/d20121211-1674-zs83qu/gmcjhLqq" "-c" "quit".
gm convert: Postscript delegate failed (MPLS.pdf).
I tryied to apply this : http://thomas-genin.com/ghostscript-convert-error-undefined-in-findresource/ and it creates this error.
EDIT: If I remove the /var/lib/ghostscript/fonts/cidfmap file I don't have the error anymore.
1 /Arial << /FileType /TrueType /Path (/usr/share/fonts/truetype/msttcorefonts/arial.ttf) /SubfontID 0 /CSI [(Artifex) (Unicode) 0] >> ;
You don't say what version of Ghostscript you are using, and because you are using something which executes Ghostscript you haven't given me a command line I can actually try.
However, on the assumption that the (ImageMagick?) command line in the error is the one being used, I rendered your PDF file to PNM without problems using a copy of the current code, so I suspect that this is resolved, I would recommend you upgrade to the current version.
If this doesn't solve the problem, then you should open a bug report at http://bugs.ghostscript.com please attach the PDF file there, and supply a Ghostscript command line which demonstrates the problem.
So I want to use Ghostscript to convert files that are created in PCL format to PostScript.
That's the gist of my problem. I am simply trying to run it on the command line, but in the final stage it will have to be run on a lp command like
lp -d < gs something something
GPL Ghostscript 9.00 (2010-09-14)
I will be running this on a Solaris 10 server but I believe any Unix system should work similar.
bash-3.00# /usr/local/bin/gs -sDEVICE=pswrite -dLanguageLevel=1 -dNOPAUSE -dBATCH -dSAFER -sOutputFile=output.ps cms-form.pcl
GPL Ghostscript 9.00 (2010-09-14)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /undefined in &k2G-210z100u0l6d0e63fa0V
Operand stack:
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1910 1 3 %oparray_pop 1909 1 3 %oparray_pop 1893 1 3 %oparray_pop 1787 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:1154/1684(ro)(G)-- --dict:0/20(G)-- --dict:77/200(L)--
Current allocation mode is local
Current file position is 30
GPL Ghostscript 9.00: Unrecoverable error, exit code 1
You are using Ghostscript (gs), which cannot read-in and interprete PCL.
You should use from GhostPDL the component that interpretes PCL: the executable is called pspcl6.
Then a command like
pspcl6 ^
-o out.pdf ^
-sDEVICE=pdfwrite ^
in.pcl
should convert your PCL to PDF. For PostScript Level 2 use -sDEVICE=ps2write.
However, it may be difficult to find pre-compiled binaries of pspcl6. It's not well known, despite it being part of the Ghostscript family of products. You may need to build + compile your own version from the sources.
Update:
http://code.google.com/p/ghostscript/downloads/detail?name=ghostpdl-8.71-win32.zip
http://code.google.com/p/ghostscript/downloads/list