Trouble converting images from the command line

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jonez
Posts: 3
Joined: 2011-08-10T08:06:30-07:00
Authentication code: 8675308

Trouble converting images from the command line

Post by jonez »

Hi, this is my first time using GhostScript/ImageMagick and after moving a website from a shared server to a dedicated box I'm trying to convert a PDF into a JPG to get around an ASP server component that was installed in the old shared environment. The new server has ASP/PHP and I have remote access to install whatever is needed. The goal is to use these with PHP to generate thumbnails of 1 page PDF's.

As a test I downloaded GhostScript/ImageMagick and installed them on my workstation (32bit), did a test "convert test.pdf test.jpg" and it worked. I then installed both components on the server (64bit versions) and tried to use the same command and keep getting the error:

Code: Select all

M:\>convert m:\test.pdf m:\test.jpg
Magick: '%s' (%d) "gswin32c.exe" -q -dQUIET -dPARADOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" "-sOutputFile=C:/Users/FMG762~2/AppData/Local/Temp/magick-0fi2JsuQ--0000001" "-fC:/Users/FMG762~2/AppData/Local/Temp/magick-cRYPzFz1" "-fC:/Users/FMG762~2/AppData/Local/Temp/magic-uF-h21Sm" @ error/utilitiy.c/SystemCommand/1988.

Magick: Postscript delegate failed 'm:\test.pdf': No such file or director @ error/pdf.c/ReadPDFImage/664.
Magick: missing an image filename 'M:\test.jpg' @ error/convert.c/ConvertImageCommand/3015
I'm not sure what's going wrong since I followed the exact same steps on the server as I did on my workstation, the only difference being one is 32bit and one is 64bit (the correct versions were installed on each). I read through a few threads on here and I don't think it's a syntax problem since it works on one and not the other but the error makes it sound like it can't find the files? Any ideas on what I'm doing wrong?

Thanks in advance!
User avatar
whugemann
Posts: 289
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: Trouble converting images from the command line

Post by whugemann »

I'm meeting the same problem under Windows Server 2008 R2. Obviously, something is going wrong with the GhostScript call initiated by ImageMagick, but I can't figure out what's going wrong here. The program file of GhostScript's 64 bit version is called gswinc32.exe, just like that of the 32 bit version.

I think that IM just tries to call Ghostscript to produce a temporary file. It then reads this temporary file and converts it to the desired format. So we have to figure out what's wrong with IM's call to GhostScript.

I could invoke GhostScript by using the command line provided by ImageMagick's error output directly in a DOS box. I however don't know what the starting of the line '%s' (%d) expands to. I don't see that explained anywhere in the documentation (?).
Wolfgang Hugemann
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Trouble converting images from the command line

Post by anthony »

Could it be the registry location of ghostscript that IM uses?

Wolfgang: Perhaps you like to submit something about Ghostscript and Registry to the IM Examples Windows Usage page.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
whugemann
Posts: 289
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: Trouble converting images from the command line

Post by whugemann »

anthony wrote: Wolfgang: Perhaps you like to submit something about Ghostscript and Registry to the IM Examples Windows Usage page.
Well, I intend to. (The Windows Usage page needs an update anyway.) But as you can tell by my "64 bit question", I still have some questions that could be answered more easily by one of the developers. Perhaps I should take a look at the source code -- what I have never done so far.
Wolfgang Hugemann
jonez
Posts: 3
Joined: 2011-08-10T08:06:30-07:00
Authentication code: 8675308

Re: Trouble converting images from the command line

Post by jonez »

Has anyone found a solution to this problem? Thanks!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Trouble converting images from the command line

Post by anthony »

Sorry......

From an older discussion, the blog explains the registry fault.
http://hallsoftech.blogspot.com/2011/07 ... image.html

Essentually ghostscript was not installed such that it added appropriate registry entries so other programs can find it.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
whugemann
Posts: 289
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: Trouble converting images from the command line

Post by whugemann »

Anthony,

I have just tested the hint that is given at the page that you linked; it doesn't do the trick. On our server, the paths are set correctly. I de-installed ImageMagick and GhostScript completely and then installed the newest versions of first GhostScript and then ImageMagick, both 64 bit. I looked in the Registry and found that all paths were given correctly. And the bug is still there.

The problem that the author describes is very special, as he obviously put GS in another location after installing it. Well, this can of course not work. I also drew from the path names given in his Registry code that he installed the 32 bit version.

As of 9.0, the executable of the 64 bit version is named gswin64.exe (instead of gswin32.exe). What's different in Win64 is that x64 executables and x32 executables are stored in different location, i.e. in the English version
*x64: C:\Program Files\
*x32: C:\Program Files (x86)\

I saw that these paths are provided as is in the GS entries in the Registry, without referring to the environment variables %PROGRAMFILES% or %PROGRAMFILES(X86)%", which might also be a source of error, as the actual installation paths are named differently in international versions, e.g. "c:\Programme\" and "c:\Programme (x86)" in German.

To put it short: This doesn't seem to be the solution.
Wolfgang Hugemann
jonez
Posts: 3
Joined: 2011-08-10T08:06:30-07:00
Authentication code: 8675308

Re: Trouble converting images from the command line

Post by jonez »

It's definitely a path issue. I installed the 32bit version into C:\Program Files (to make it install to where it would on a 32bit OS), copied my test.pdf file into C:\Program Files\gs\gs9.04\bin and tried "convert test.pdf test.jpg" and it worked. Oddly enough I can't call this from say C:\ it has to be in the folder containing gswin32c.exe.

Is there any way to manually tell it where GS is installed?

[edit]
Installing the 32bit versions of both ImageMagick and GS in C:\Program Files instead of C:\Program Files (x86) seems to work. I don't think the paths to GS in the 64bit version of ImageMagick are looking in the right place. If anyone finds a solution to using the 64bit versions of both components instead of the 32bit versions on a 64bit OS please reply!
[/edit]

[edit2]
Just wanted to say thanks for the great software! I have it implemented in the site and it does everything I'd hoped for and more!
[/edit2]
Post Reply