Do we need to install vs 2012 on server to use ImageMagick?

Jun 5, 2014 at 6:38 AM
Edited Jun 5, 2014 at 6:47 AM
I am getting below error on server while converting PDF to Image.

Could not load file or assembly 'Magick.NET-Q16-x86.dll' or one of its dependencies. The specified module could not be found.

My server OS is 64 bit.

I have already installed .NET 4.0: Visual C++ Redistributable on server but I have not installed vs 2012.

Is necessary VS 2012 to install on server for using ImageMagick?

Can you please help me to get rid out of this problem.

Thanks in advanced.
Coordinator
Jun 5, 2014 at 7:14 AM
You don't need to install VS 2012 on your server. You probably only installed the x64 version of the Visual C++ Redistributable 2012. You should install the x86 version of the redistributable if you want to use Magick.NET-Q16-x86.

If you want to convert a PDF file to an image make sure you also install Ghostscript on your server.
Jun 5, 2014 at 12:27 PM
Thanks for your reply.

I have already install all things as you mentioned. So still I am getting below error:

Could not load file or assembly 'Magick.NET-Q16-x86.dll' or one of its dependencies. The specified module could not be found.

Thanks.
Coordinator
Jun 5, 2014 at 12:30 PM
Did you reboot your server? And are you using the .NET 4.0 version of Magick.NET?
Jun 5, 2014 at 12:35 PM
Yes, we are using .NET 4.0 version of Magick.NET. No, still we have not reboot server. Is it needed?
Coordinator
Jun 5, 2014 at 12:41 PM
I don't know if it is necessary to reboot after your install 'Visual C++ Redistributable 2012 x86. The error message 'The specified module could not be found.' is an error that will be raised when the C++ Redistributable cannot be found. I suggest you should try to see if a reboot will resolve your issue.
Jun 10, 2014 at 5:24 AM
Thanks dlemstra.

The above error is now fixed but imagemagick cannot save converted image to folder on server. It is working fine in my local.

Please help me for get rid of this.

Thanks in advanced.
Coordinator
Jun 10, 2014 at 8:06 AM
What do you mean by 'cannot save'? What is the error/exception you are receiving?
Jun 10, 2014 at 8:28 AM
I meant that in our local environment, image is saved to folder but on server, image is not saved to the folder.

Any guesses, what is the problem?

Thank You,

Vimal
Coordinator
Jun 10, 2014 at 10:02 AM
I really need more information, what is the error you are receiving? How are you writing the image?

Your question is like me asking you why my car won't start. And if you can fix it for me.
Jun 10, 2014 at 10:23 AM
Surprise for me is that, there is no error occurs. Below is my code:

if (!Page.IsPostBack)
    {
        MagickReadSettings settings = new MagickReadSettings();
        settings.Density = new MagickGeometry(300, 300);
        settings.FrameIndex = 0;
        settings.FrameCount = 1;
        using (MagickImageCollection images = new MagickImageCollection())
        {
            images.Read(Server.MapPath(@"2014_HPP_Plan_2-11-14_REV.pdf"), settings);
            int page = 1;
            foreach (MagickImage image in images)
            {
                image.Write(Server.MapPath("~/developeruploads/Snakeware.Page.jpg"));
            }
        }
    }
Please review code and let me know if there is any problem.

Thank You,

Vimal
Coordinator
Jun 10, 2014 at 10:58 AM
Maybe your live environment is writing the output somewhere else then you are expecting. Can you search your server for the file 'Snakeware.Page.jpg'?

And can you try it without 'Server.MapPath'? Magick.NET 'understands' the '~' and uses 'AppDomain.CurrentDomain.BaseDirectory'.
images.Read(@"~\2014_HPP_Plan_2-11-14_REV.pdf"), settings);
// AND
image.Write(@"~\developeruploads\Snakeware.Page.jpg"));
Jun 10, 2014 at 11:16 AM
Thanks for your reply.

I have already tried search with the file name 'Snakeware.Page.jpg' in whole drive in server but I could not find it. I think that imagemagick is not converted pdf to images in server.

We will try your code.

Thank You,

Vimal
Coordinator
Jun 10, 2014 at 11:23 AM
Did you install Ghostscript on your server?
Jun 10, 2014 at 11:29 AM
Edited Jun 10, 2014 at 1:20 PM
Yes, I have installed Ghostscript on server 32 and 64 bit both but still it is not working.
Coordinator
Jun 10, 2014 at 1:42 PM
Can you try to see what happens when you write to a full path, for example: image.Write(@"c:\test\Snakeware.Page.jpg")?
Jun 11, 2014 at 8:39 AM
Thank you for your help.

Now it is working fine. Problem was with Ghostscript. Earlier 32 bit exe could not installed but yesterday once I tried and it installed and seems to work fine.

Thank You Very much,

Vimal
Jun 20, 2014 at 6:36 AM
Conversion of PDFs to images is working fine in DEV site but it gives me error on LIVE site.
Error is "Failed to load embedded assembly: Access is denied. "

We are using Magick.NET-AnyCPU.dll

Can you please help me to get rid of this problem?

Thanks,

Vimal
Coordinator
Jun 20, 2014 at 6:41 AM
The AnyCPU library will try to write it's embedded assembly to a temporary directory but it seems it is not allowed to write anything there. You can set the directory with the following property:
MagickAnyCPU.CacheDirectory = @"C:\path\to\your\temp\directory";
Jun 20, 2014 at 6:51 AM
Should I have to create a directory inside temporary directory?
Coordinator
Jun 20, 2014 at 7:07 AM
You need to specify a directory that is outside your wwwroot but writable by your application. The AnyCPU library will create a directory inside the directory you specify.
Jun 20, 2014 at 9:34 AM
Which DLL I can use instead of AnyCPU ?

Can you please tell us? We are using 64 bit operating systems.

Thanks,

Vimal
Coordinator
Jun 20, 2014 at 10:07 AM
If your application pool is running in 64 bit mode you can use the x64 version of Magick.NET.