7

I'm using ImageMagick to convert PDF files to PNG. Running the process from my Web API project locally works as long as I run Visual Studio as admin. When moving the solution to the server the ImageMagick process fails with the following error

convert.exe: unable to load module `C:\Program Files\ImageMagick-6.9.0-Q16\modules\coders\IM_MOD_RL_PNG_.dll': The specified module could not be found.

I have both ghostscript and ImageMagick installed as they should be on the server. What could be a cause for this? I can verify that the module does in fact exist on the server.

Stavros_S
  • 2,145
  • 7
  • 31
  • 75

6 Answers6

7

The solution to this problem in my situation was to set the environment variable for ImageMagick directly in the code where I was calling the process.

System.Environment.SetEnvironmentVariable("Path", @"C:\Program Files\ImageMagick-6.9.0-Q16");

Apparently even if the environment variable is set on the server, it may not find it due to the runtime being different.

Stavros_S
  • 2,145
  • 7
  • 31
  • 75
3

In my case, after a fresh installation of Imagemagick, I got simillar error (unable to load module). What helped was simple:

Reboot the system

It's probably 'cause PATH system variable or something like this has to take effect.

hejdav
  • 1,267
  • 15
  • 19
  • Jesus Christ... Used hours on troubleshooting this error, thank you. These errors in imagestick are just way off in my opinion. – Unicco Aug 23 '17 at 11:15
2

In my case, I was able to solve this using the portable version so it doesn't have to find anything as it's all embedded on the exe.

Alfergon
  • 5,463
  • 6
  • 36
  • 56
  • Thank you, portable version works absolutely great in case ImageMagick is called from another application (not just in command line). – Candice Dec 01 '16 at 22:14
0

If you just installed ImageMagick and you are trying to run this from the command line, you will need to open a new command line window that has the updated %PATH% environment variable.

You could try something with SETX, but opening a new command line window seems a lot easier.

James John McGuire 'Jahmic'
  • 11,728
  • 11
  • 67
  • 78
0

Restart your Visual Studio or any IDE (Even your command prompts, close and open them again).

System Path not being updated, is causing this error in my situation.

Kishore
  • 29
  • 1
  • 4
0

Can Imagemagick be used to find libpng? Is it actually installed? Are you calling the ImageMagick convert.exe or the Windows convert.exe?

convert.exe -version

should show png in the list of delegates? What are you finding from that command?

fmw42
  • 46,825
  • 10
  • 62
  • 80