Ghostscript eps file conversion to jpg not working inside the .NET application

25 Views Asked by At

I am working on a project a .NET application which generates preview and thumbnail images with the help of imagemagick and Irfanview applications. Since Imagemagick not supporting the conversion of .eps format files, I have tried using Ghostscript GPL v10.02.1 in the project. So I have tried the following command inside the bin folder of the ghostscript application in my local machine and it has successfully converted the file from .eps to .jpg format. But when I used the same arguments in the project it is not working, it always returns the exit code as 1. The arguments I have used:

gswin64c.exe -dNOPAUSE -sDEVICE=pngalpha -dEPSCrop -r300 -sOutputFile=output.png EPS.eps

````I have tried this code below but ghostscriptResult always returns exit code as 1, but expects 0.

 bool isEps = string.Compare(Path.GetExtension(image.Filename), ".eps", true) == 0;
 string epsFilePath = image.Filename;
 string jpgOutputPath = Path.Combine(PreviewLocation, Path.ChangeExtension(Path.GetFileName(image.Filename), ".jpg"));
 string ghostscriptCommand = string.Format(GhostscriptArguments, epsFilePath, jpgOutputPath);
 var ghostscriptResult = RunProcess(WorkingDirectory, GhostscriptPath, ghostscriptCommand, TimeSpan.FromMinutes(2));
0

There are 0 best solutions below