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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With