Reputation: 1924
I have found that most documentation about using ImageMagick with ghostscript says to just declare path to ghostscript dll like
MagickNET.SetGhostscriptDirectory(AppDomain.CurrentDomain.BaseDirectory);
Then using the MagickImage like:
using (var image = new MagickImage(streamToConvert))
{
image.Write(outputStream);
}
Now I have an azure site and can´t make a path like that.
I want to import Ghostscript.NET nuget package in Visual Studio but then I don´t know how to go on, that is declare to MagickImage where to find Ghostscript. How can I do this?
Upvotes: 2
Views: 1258
Reputation: 1924
Ended up with importing nuget package Ghostscript.NET and used Ghostscript method to create a "screenshot" of image to then put it into MagickImage.
_lastInstalledVersion =
GhostscriptVersionInfo.GetLastInstalledVersion(
GhostscriptLicense.GPL | GhostscriptLicense.AFPL,
GhostscriptLicense.GPL);
_rasterizer = new GhostscriptRasterizer();
_rasterizer.Open(streamToConvert, _lastInstalledVersion, true);
ConvertWithGhostscript(streamToConvert, ghostStream);
ConvertWithImageMagick(ghostStream, outputStream, image.Extension);
image.Write(outputStream);
Upvotes: 0
Reputation: 2079
Just copy the Ghostscript dlls into your project and use "copy always" setting. Then your Ghostscript files will end up in the correct folder when you publish.
Now when in Azure things are not quite as you would expect when developing on your desktop so look at this before going any further. How to store temp files in Azure
Upvotes: 1