A simple image converter
public class ConvertInheritance System.Object 🡒 Convert
Usage as follows:
public void ToWebpTest(string inputPath, string outputPath)
{
Convert.To(inputPath, outputPath, ImageMagick.MagickFormat.WebP);
Assert.IsTrue(File.Exists(outputPath));
var fi = new FileInfo(outputPath);
Console.WriteLine(fi.Length);
Assert.IsTrue(fi.Length > 1);
} For supported formats refer to
ImageMagick.MagickFormat
Convert an image data of any popular format to another format data
public static byte[] To(byte[] input, ImageMagick.MagickFormat format=ImageMagick.MagickFormat.Png, int quality=90);input System.Byte[]
The input.
format ImageMagick.MagickFormat
The format.
quality System.Int32
The quality. Default 90. It can be 0 - 100.
System.Byte[]
converted image data
Convert an input image from a specified path to any popular format and save to another specified path
public static void To(string inputPath, string outputPath, ImageMagick.MagickFormat format=ImageMagick.MagickFormat.Png, int quality=90);inputPath System.String
The input path.
outputPath System.String
The output path.
format ImageMagick.MagickFormat
The format.
quality System.Int32
The quality. Default 90. It can be 0 - 100.
Convert an image stream of any popular format to another format stream
public static void To(System.IO.Stream inputStream, System.IO.Stream outputStream, ImageMagick.MagickFormat format=ImageMagick.MagickFormat.Png, int quality=90);inputStream System.IO.Stream
The input stream.
outputStream System.IO.Stream
The output stream.
format ImageMagick.MagickFormat
The format.
quality System.Int32
The quality. Default 90. It can be 0 - 100.