public static IMagickFormatInfo GetFormatInformation(Stream stream) { var startPosition = stream.Position; try { var info = new MagickImageInfo(stream); return(MagickNET.GetFormatInformation(info.Format)); } catch { stream.Position = startPosition; return(GetFormatInformationFromHeader(stream)); } finally { stream.Position = startPosition; } }
private static void ExtractLibrary() { #if Q8 string name = "Magick.NET-Q8-" + (NativeLibrary.Is64Bit ? "x64" : "x86"); #elif Q16 string name = "Magick.NET-Q16-" + (NativeLibrary.Is64Bit ? "x64" : "x86"); #elif Q16HDRI string name = "Magick.NET-Q16-HDRI-" + (NativeLibrary.Is64Bit ? "x64" : "x86"); #else #error Not implemented! #endif string cacheDirectory = CreateCacheDirectory(); string tempFile = Path.Combine(cacheDirectory, name + ".Native.dll"); WriteAssembly(tempFile); WriteXmlResources(cacheDirectory); NativeMethods.SetDllDirectory(cacheDirectory); MagickNET.Initialize(cacheDirectory); }
private IImageOptimizer GetOptimizer(Stream stream) { long position = stream.Position; MagickImageInfo imageInfo = new MagickImageInfo(stream); stream.Position = position; MagickFormatInfo info = MagickNET.GetFormatInformation(imageInfo.Format); foreach (IImageOptimizer optimizer in _optimizers) { if (optimizer.Format.Module == info.Module) { return(optimizer); } } if (IgnoreUnsupportedFormats) { return(null); } throw new MagickCorruptImageErrorException("Invalid format, supported formats are: " + SupportedFormats); }
private static MagickFormat GetModule(MagickFormat format) { MagickFormatInfo formatInfo = MagickNET.GetFormatInformation(format); return(formatInfo.Module); }
///<summary> /// Returns the format information. The extension of the supplied file is used to determine /// the format. ///</summary> /// <param name="file">The file to check.</param> public static MagickFormatInfo Create(FileInfo file) { return(MagickNET.GetFormatInformation(file)); }
///<summary> /// Returns the format information of the specified format. ///</summary> ///<param name="format">The image format.</param> public static MagickFormatInfo Create(MagickFormat format) { return(MagickNET.GetFormatInformation(format)); }