Page 1 of 1

Error creating resized image through .NET web service

Posted: 2014-07-08T08:36:34-07:00
by tharidass
The web service in our app calls image magick to create resized files. Some how one of the profiles does not get created it is the files starting with small_ . When I call image magick on the command line in the same machine with these arguments all sizes are getting created. The web service is a ASP.NET webservice that runs on Windows 2008R2 under an app pool for .NET 4.0 and supports 32-bit too.

"\\server1\folder1\6367504.jpg" ( -clone 0 -resize 75x59! -quality 92 -bordercolor #ffffff -mattecolor #ffffff -frame 0x0 -write "\\server1\folder1\small_6367504.jpg" +delete ) ( -clone 0 -resize 91x72! -quality 92 -bordercolor #ffffff -mattecolor #ffffff -frame 0x0 -write "\\server1\folder1\spotlight_6367504.jpg" +delete ) ( -clone 0 -resize 120x95! -quality 92 -bordercolor #ffffff -mattecolor #ffffff -frame 0x0 -write "\\server1\folder1\homnb_6367504.jpg" +delete ) ( -clone 0 -resize 180x143! -quality 92 -bordercolor #ffffff -mattecolor #ffffff -frame 0x0 -write "\\server1\folder1\homthumb_6367504.jpg" +delete ) ( -clone 0 -resize 384x307! -quality 92 -bordercolor #ffffff -mattecolor #ffffff -frame 38x0 -write "\\server1\folder1\hommain_6367504.jpg" +delete ) null:

Please let me know if you have any clues or solution to troubleshoot it also provide some tips on how to make image magick emit log for this.

Re: Error creating resized image through .NET web service

Posted: 2014-07-08T12:41:57-07:00
by dlemstra
How do you call ImageMagick are you calling the command line or are you using my wrapper Magick.NET?

Re: Error creating resized image through .NET web service

Posted: 2014-07-08T12:43:31-07:00
by tharidass
I call the Convert.exe 32 bit exe from the web service using System.Diagnostics.Process class.

Re: Error creating resized image through .NET web service

Posted: 2014-07-08T12:49:20-07:00
by dlemstra
Can you post how you call convert.exe? Maybe you are providing incorrect arguments? You could check the stdout/stderr output from the Process class to see why it is not working.

Re: Error creating resized image through .NET web service

Posted: 2014-07-08T12:51:44-07:00
by tharidass
Thank you for your help. Here is the C# code that call the exe.

var cla = new ProcessStartInfo();

cla.FileName = _imageMagickCovertPath;
cla.Arguments = args.ToString();
cla.UseShellExecute = false;
cla.CreateNoWindow = true;
cla.RedirectStandardError = true;
cla.RedirectStandardOutput = true;
var resizer = Process.Start(cla);
string message = resizer.StandardOutput.ReadToEnd();
string error = resizer.StandardError.ReadToEnd();

resizer.WaitForExit(_imageMagickTimeout * 1000);

if (!resizer.HasExited)
{
if (!string.IsNullOrEmpty(_taskKillPath))
{
Process objTaskKill = new Process();
objTaskKill.StartInfo.FileName = _taskKillPath;
objTaskKill.StartInfo.Arguments = "/F /PID " + resizer.Id.ToString();
objTaskKill.Start();
throw new ResizeException(string.Format("Killing ImageMagick: message: {0} working folder: {3} args for convert.exe : {1} error: {2}", message, args, error, cla.WorkingDirectory), Enums.ResizeError.Unspecified);
}
else
{
resizer.CloseMainWindow();
resizer.Close();
}
}
else
{
int exitCode = resizer.ExitCode;
if (exitCode > 0)
{
throw new ResizeException(string.Format("Error while resizing: message: {0} working folder: {4} args for convert.exe : {1} exit code:{2} error: {3}", message, args, exitCode, error, cla.WorkingDirectory), Enums.ResizeError.Unspecified);
}
}

Re: Error creating resized image through .NET web service

Posted: 2014-07-09T08:12:33-07:00
by tharidass
I did some testing and found out that ImageMagick works perfectly. The problem is that the web service that calls the image magick actually locks the files generated by image magick. The IIS process locks the files randomly and it is not available for copying to target folder.

Thanks for all your help. I will post on how I fixed the web service process to solve this issue.