I cannot figure out where I need to put files for ImageMagick to process them. I am trying to use it in my ASP.NET MVC website and having zero luck having it find my files to process. And if it does how do I specify where they will be output?
I have been looking here and I mut be missing something:
http://www.imagemagick.org/script/command-line-processing.php
Here is my code to call the process:
//Location of the ImageMagick applications
private const string pathImageMagick = @"C:\Program Files\ImageMagick-6.7.3-8";
private const string appImageMagick = "MagickCMD.exe";
CallImageMagick("convert -density 400 SampleCtalog.pdf -scale 2000x1000 hi-res%d.jpg");
private static string CallImageMagick(string fileArgs)
{
ProcessStartInfo startInfo = new ProcessStartInfo
{
Arguments = fileArgs,
WorkingDirectory = pathImageMagick,
FileName = appImageMagick,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true
};
using (Process exeProcess = Process.Start(startInfo))
{
string IMResponse = exeProcess.StandardOutput.ReadToEnd();
exeProcess.WaitForExit();
exeProcess.Close();
return !String.IsNullOrEmpty(IMResponse) ? IMResponse : "True";
}
}
We do something similar but use the environment variables (which is advantageous because it works on every system) to execute cmd.exe which we feed with convert and the parameters. This is how we create the ProcessStartInfo object:
Then we read from proc.StandardOutput in order to get error messages and result codes. Afterwards, we destroy the objects.
Sorry if this is not 100%, I copied it from a more complex OO code.