Azure function with Ghostscript works properly in local (on my Mac computer), but when tried to deploy on Azure, doesn't work

121 views Asked by At

I am using the Ghostscript in my C# dot.net core 6 azure function to convert pdf documents into png images, which works well in the local environment. However, when I tried to deploy it to Azure from my VS Code and test it, spotted that pdfs are not converted into png images. Looking into logs, I see the following error:

An error occurred during PDF to PNG conversion: An error occurred trying to start process './ghostscript/10.01.2/bin/gs' with working directory '/'. No such file or directory

Here is the relevant part of the code:

                var ghostscriptArgs = $"-q -dQUIET -dBATCH -dNOPAUSE -sDEVICE=pngalpha -r150 -sOutputFile=\"{tempDirectory}/output-%03d.png\" \"{tempFilePath}\"";
            var ghostscriptProcessInfo = new ProcessStartInfo
            {
                FileName = "./ghostscript/10.01.2/bin/gs",
                Arguments = ghostscriptArgs,
                RedirectStandardOutput = true,
                RedirectStandardError = true,
                UseShellExecute = false,
                CreateNoWindow = true
            };

Here is the folder with ghostscript, placed in the project root: enter image description here

And here is the project file: enter image description here

Any idea where I am making a mistake? Thanks.

0

There are 0 answers