Saturday, July 9, 2011

Image Magick error "missing an image filename" SOLVED

If you've ever experienced the error in Image Magick that states "missing an image filename", it may or may not state also that it can't find a file.  In my case, I found the solution.  There are many people online that tried various things, including running the Image Magick configure command, modifying the delegates.xml file, etc., but none of those worked for me.  I have two different systems I could compare.  One worked and the other did not.  After retracing my installation steps, I realized the one thing I did differently was on the system that did not work.  I installed GhostScript, but then realized I didn't have it in the path I wanted it, so I renamed the path and changed the GS_PROG environment variable, but I didn't realize that there were registry entries that did matter to Image Magick to identify the location of GhostScript.  This would also apply in situations where the GhostScript files are manually copied to the system.  The environment variable GS_PROG is not sufficient to be correctly pointed at the GhostScript folder.   (I haven't investigated when these registry entries get created yet, but they are apparently necessary for Image Magick to properly find GhostScript.)

In my case, I originally installed GS in the folder "C:\Program Files\gs\gs9", but I wanted it in the folder "C:\Program Files\GhostScript\gs9", which is how I discovered this solution.  I've verified that this solution works by copying the installed GhostScript folder to another computer, set the GS_PROG environment variable, and applied these registry entries.  The registry entries that resolved this are:

[HKEY_LOCAL_MACHINE\SOFTWARE\Artifex\GPL Ghostscript\9.02]
@="C:\\Program Files\\GhostScript\\gs9"

"GS_DLL"="C:\\Program Files\\GhostScript\\gs9\\bin\\gsdll32.dll"
"GS_LIB"="C:\\Program Files\\GhostScript\\gs9\\bin;C:\\Program Files\\GhostScript\\gs9\\lib;C:\\Program Files\\GhostScript\\gs9\\fonts"

There is a registry section for uninstalling GhostScript as well that had a reference to the GS folder:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\GPL Ghostscript 9.02]

...includes a line that needed to be modified.  The entire section is:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\GPL Ghostscript 9.02]
"DisplayName"="GPL Ghostscript"
"UninstallString"="\"C:\\Program Files\\GhostScript\\gs9\\uninstgs.exe\""
"Publisher"="Artifex Software Inc."


Anonymous said...

Hello, I write from Italy, I apologize for grammar errors :( !
I'm trying to convert a PDF file into image and to do this I use PHP 5.2.12, Imagemagick 6.7.2 and GhostScripts 9.02 (my OS is Windows XP and I have Apache 2.2.14).
When I try a simple test I get the following error:
"Postscript delegate failed `C:\Programmi\Apache Software Foundation\Apache2.2\htdocs\somefile.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/664 "

(obviously the file is in the right directory)

This is the PHP code:
I have read your answer but I have not figured out how I can use it to solve my problem.

I have Apache in directory:
"C:\Programmi\Apache Software Foundation\Apache2.2"
and GhostScript in:
and PHP in:
where is the problem??? There is something in these 3 directories that can cause the error I reported above?
Thanks in advance.
Apio, greetings from Italy.

Ken said...

Apio, No need to apologize for your English grammar, my Italian grammar is non-existent, so you're a step ahead of me!

I probably should have mentioned in my post that my environment was a Windows system running the commands at the command line. The concept for the solution may be similar. ImageMagick may still not be finding the file's it needs, so let's assume for a start that the error reported is correct, and that there is something about the paths somehow with IM that isn't connecting.

I do have access to a PHP environment that I can try to reproduce your situation if needed, but it is server-based. Let's start with these ideas and questions:

1) Can you export and post your registry entries for the following:

2) Can you verify that your environment variable "GS_PROG" exists and equals "C:\Programmi\gs\gs9.02\gswin32c.exe". This variable should be defined as a System variable in your OS and should show when yo type "SET" at a DOS prompt.

3) Where is your ImageMagick installed?

4) Can you try a basic command line example to make sure ImageMagick is working. Can you post what command you use for the test?

Once we can verify that IM works at the command line, we need to check how PHP is accessing IM. I believe there will be either a PHP variable or an explicit path for PHP to find ImageMagick. Can you determine what that is? It will likely be in the phpinfo() output.

Let's start with that and see what it turns up. Item #2 above is important.

Anonymous said...

Hello, I'm from Ukraine, so I apologize for grammar errors too )
I'm trying to convert a eps file to jpg using ImageMagick, the ghostscript is also installed. When I execute "convert -density 300 file.eps -resize 1024x1024 image.jpg" I don't get any error, the image.jpg exists, but I cannot open it due to bad format. I can see that there is some xml markup inside ( Could you advise me something?

Anonymous said...

To other people who might run across this blog; I've also gotten this when a project using its own 32-bit executable of ImageMagick tried using the 64-bit version of GhostScript I had installed.

Installing the 32 bit version of GhostScript fixed the issue for me.

Post a Comment