using ImageMagick; MagickImage image = new MagickImage(); image.Read("input.jpg"); // Modify the image image.Resize(new MagickGeometry(200, 200)); image.Grayscale(); // Save the modified image to disk image.Write("output.jpg");
using ImageMagick; using System.IO; // Load the image from a byte array byte[] imageData = File.ReadAllBytes("input.jpg"); MagickImage image = new MagickImage(imageData); // Apply a filter to the image image.FilterType = FilterType.Sinc; image.AdaptiveResize(new MagickGeometry(800, 600)); // Save the modified image to disk image.Write("output.jpg");
using ImageMagick; using System.IO; // Load the image from a file MagickImage image = new MagickImage("input.jpg"); // Modify the image image.Rotate(90); // Get the image as a byte array byte[] imageData = image.ToByteArray(); // Save the byte array to a new file File.WriteAllBytes("output.jpg", imageData);This example loads an image from a file (input.jpg) and rotates it by 90 degrees. Then, it gets the image as a byte array using the Blob property, and saves it to disk with a new name (output.jpg). Overall, these examples demonstrate the power and flexibility of ImageMagick's MagickImage class in C#. With its rich set of methods and properties, it provides developers with a powerful toolset to manipulate images in a wide range of scenarios.