Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting ImageMagick process on windows server failing with "the specified module could not be found."

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.

like image 278
Stavros_S Avatar asked Apr 03 '15 17:04

Stavros_S


3 Answers

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.

like image 144
Stavros_S Avatar answered Oct 15 '22 11:10

Stavros_S


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.

like image 44
hejdav Avatar answered Oct 15 '22 11:10

hejdav


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.

like image 2
Alfergon Avatar answered Oct 15 '22 09:10

Alfergon