Imagick fails to execute gs command - ghostscript

I can successfully convert some pdfs to pngs but some throw this error:
ImagickException: FailedToExecuteCommand `'gs' -sstdout=%stderr
-dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r144x144' -dFirstPage=1 -dLastPage=1 '-sOutputFile=/tmp/magick-966AGfRi74eBSiG%d'
'-f/tmp/magick-966t0bB45paDzcW' '-f/tmp/magick-966l4St1G1Jfh6b'' (-1)
# error/delegate.c/ExternalDelegateCommand/462
I have a hard time to move forward as I don't understand nothing of the error msg.
What can be the problem?

I was getting that same error in Ubuntu using ghostscript version 9.26. After additionally installing ghostscript-x with apt-get update && apt-get install -y ghostscript-x the problem was solved.

Duplicate of this question:
ghostscript 9.26 update breaks imagick readImage for multipage PDF
But I can't mark this as a duplicate as the answer has neither been accepted or upvoted.

Related

imagemagick won't recognize new path to Ghostscript

I'm trying to convert some PDFs to jpegs using imagemagick . I'm working on win 10, 64 with python 3.62 - 64 bit and wand 0.4.4. I've been able to get wand working with ImageMagick-6.9.9-Q16-HDRI. I have all this set up on a E USB flash drive. I've set both the Path and MAGICK_HOME env vars to
E:\ImageMagick-6.9.9-Q16-HDR;E:\gs\bin
Originally I installed ghostscript 9.22 - 64 at E:/gs9.22 , but the I read ( PythonMagick can't find my pdf files) that 64 bit may not work so I deleted that and got ghostscript 9.22 - 32 bit, which I installed as above.
I ran:
$ convert myfile.pdf test.jpg
convert.exe: FailedToExecuteCommand `"E:/gs9.22/bin/gswin64c.exe" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=png
alpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" "-sOutputFile=C:/Users/MYaCCount/AppData/Local/Temp/magick-9524p6yKrXNmpJc3%d" "-fC:/Users/MYaCCount/AppData/Local/Te
mp/magick-9524TRGHmKoW5SkX" "-fC:/Users/MYaCCount/AppData/Local/Temp/magick-9524pKGelk0Un3Bp"' (The system cannot find the file specified.
) # error/delegate.c/ExternalDelegateCommand/459.
convert.exe: PDFDelegateFailed `The system cannot find the file specified.
' # error/pdf.c/ReadPDFImage/809.
convert.exe: no images defined `test.jpg' # error/convert.c/ConvertImageCommand/3258.
Why is the system looking for the 64 bit ghostscript path (which I deleted) ? I have closed and reopened my editor and the environmental var editor.
I ended up using the regedit utility to manually go through and remove all traces of 'ImageMagick'. The included uninstall utility in Imagemagick did not remove everything. After this I was able to install new versions.

PDF to PNG conversion using Ghostscript: only the fist page is in the output PNG file

I am using Ghostscript on Windows 7 machine to convert PDF to PNG. My input PDF has many pages but the PNG file only contain the first page !
I am using the following command line:
gswin64c -sDEVICE=png16m -r720x720 -dNOPAUSE -dBATCH -sOutputFile=79245340005_1602.png 79245340005_1602.pdf
and the logfile is as follow:
GPL Ghostscript 9.20 (2016-09-26)
Copyright (C) 2016 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 2.
Page 1
Page 2
As you can see, it seems that both pages are processed but only the first one appear in the final PNG file. Any idea what is wrong in my command line ? I try to look a the documentation but didn't find what I am doing wrong. If I have a single PDF file with 10 pages, I wand a single output PNG file with 10 pages.
My original command line was as follow but had the same issue:
gswin64c -q -sPAPERSIZE=a4 -sDEVICE=png16m -dTextAlphaBits=4 -r720x720 -o 79245340005_1602.png -dNOPAUSE -dBATCH 79245340005_1602.pdf
Thanks
Fabien
PNG can hold only one image per file. Use TIFF or the like for multiple images per file.
Try to use following syntax to achieve rasterizing into several png's
gswin64c -q -sPAPERSIZE=a4 -sDEVICE=png16m -dTextAlphaBits=4 -r720x720 -o -sOutputFile='79245340005_1602_%00d.png' -dNOPAUSE -dBATCH 79245340005_1602.pdf

Ghostscript 9.14 - Create PDFA from PS

I have a requirement of creating PDFA Document from PS in my LINUX environment.
I am using the following command line to generate the same:
gs -q -dPDFA=2 -sColorConversionStrategy=/RGB -dBATCH -dPDFSETTINGS=/screen -dNOPAUSE -dNOOUTERSAVE -sProcessColorModel=DeviceRGB -sDEVICE=pdfwrite -sOutputFile=pdfA_New.pdf /project/mgos/9.14/lib/PDFA_def.ps Sample.ps
I am able to create PDFA Document however the Standards show the following:
1. Standard:PDF/A-2B . This should be 2U for me.
Also the Output Intent data is missing.
Let me know if I am missing anything.
Thanks,
Arun
Ghostscript doesn't support PDF/A-2U at all, just PDF/A-2b. I really really don't recommend use of PDFSETTINGS if you plan to request PDF/A output.
And you should upgrade to Ghostscript 9.15 as well.

multi PDF TO jpeg deleting files

I have multipage PDF eg. ~ 80 pages
gs -dNumRenderingThreads=2 -c 30000000 setvmthreshold -f -dNOGC
-sDEVICE=jpeg -q -dSAFER -dNOPAUSE -dBATCH -dMaxBitmap=100000000
-dJPEGQ=100 -r300 -dPDFFitPage -dFIXEDMEDIA
-sDEFAULTPAPERSIZE=a4 -sOutputFile='.$output_name.'temp%04d.jpg $input_file
First was trying to split whole pdf but its start to show error invalidfileaccess in --showpage ...
File is ok because first i check if it's exists
Now i chunk pdf to 10 pages pdf but still is the same problem and after i run chunked pdf in loop its removeing the file with error and all others files from loop
The most likely problem is that you are running out of disk space, either on the destination or in the /tmp volume, or possibly a memory error.
You should start by simplifying the command line; get rid of the NumRenderingThreads which probably isn't doing anything at all at 300 dpi, remove the extraneous -c... -f and the -dNOGC, these are constraining the memory and preventing GS from garbage collecting, which means that its memory usage will continually increase.
Remove -dSAFER as that affects file writing. Put -sPAPERSIZE=a4 before -dFIXEDMEDIA, as the order of operands is important.
If that solves the problem put commands back one at a time until the problem recurs.
Finally, what verison of Ghostscript are you using, and please post the entire erorr trace.
Problem sloved there was strange situation with TMP DIR need to be foreach export TMP diffrent dir

ImageMagick Errors: Convert PDF to Images

When I run the following command to convert a PDF to Image using ImageMagic Convert util with the following parameters :
C:\Windows\system32>"C:\Program Files\ImageMagick-6.5.8-Q16\convert.exe" "D:\RealDocs.pptx.pdf" "d:\hello.jpg"
I get the following error :
convert.exe: `%s': %s "gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVICE=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" "-sOutputFile=C:/Users/Nupitch/AppData/Local/Temp/magick-xwOF7jbV" "-fC:/Users/Nupitch/AppData/Local/Temp/magick-BescEsek" "-fC:/Users/Nupitch/AppData/Local/Temp/magick-XfLll9WM" # utility.c/SystemCommand/1964.convert.exe: Postscript delegate failed `D:\RealDocs.pptx.pdf': No such file ordirectory # pdf.c/ReadPDFImage/634.convert.exe: missing an image filename `d:\hello.jpg' # convert.c/ConvertImageCommand/2838.
please help me ~
ImageMagick cannot handle PostScript and PDF files itself and by its own. For this it uses a third party software called Ghostscript as a 'delegate'.
Has your Windows system Ghostscript installed properly? Or is not installed at all?
Try to download and install the latest version from here.
Probably you'd get a different error message if the problem is caused by a missing Ghostscript installation. But your error is:
D:\RealDocs.pptx.pdf': No such file or directory
# pdf.c/ReadPDFImage/634.convert.exe: missing an image filename `d:\hello.jpg'
This could mean that the user account you run this command under does not have permission to write to the root of the D: drive.
To test this, you could run the conversion command in a cmd.exe window in a slightly modified way:
"C:\Program Files\ImageMagick-6.5.8-Q16\convert.exe" ^
"D:\RealDocs.pptx.pdf" ^
"%userprofile%\hello.jpg"
(On Windows XP, %userprofile% usually points to c:\documents and settings\<your username>\...)

Resources