1. Products
  2.   Image
  3.   .NET
  4.   ImageProcessor  
 
  

Open Source C# .NET Library for Images Manipulation

Read, Write, Modify, Resize & Convert PNG, JPEG, GIF & TIFF Images on-the-Fly via Free .NET API.

ImageProcessor is a free open source .NET image processing library that allows computer programmers to manipulate images on-the-fly inside their own .NET applications. The library is very fast, stable, extensible, user friendly and contains great features. The library provides full support for working with JPG, JPEG, PNG, GIF, PNG8 (both animated and static), BMP and TIFF file formats.

The library is mainly divided into to two sub libraries. The first library is known as ImageProcessor and provides full supports for working with desktop and applications. The 2nd library ImageProcessor.Web is built for ASP.NET and provides full support for working with web applications. We will be mainly discussing about the first part and how can developers use it inside their applications.

Previous Next

Getting Started with ImageProcessor

A Stable release is available on NuGet. ImageProcessor is, and will only ever be supported on the .NET Framework running on a Windows OS. Please do not attempt to use with .NET Core or NET 5+.

Install ImageProcessor via NuGet

NuGet\Install-Package ImageProcessor -Version number 

Apply Filters to Images via C# Library

The open source ImageProcessor library allows C# .NET developer to filter images with ease inside their own applications. Please use the MatrixFilters class to assign the correct filter to your images. There are several types of filters available that you can apply to your images, such as BlackWhite, Comic, Gotham, GreyScale, HiSatch, Invert, Lomograph, LoSatch, Polaroid and Sepia.

Add Text Based Watermark to Image

You can easily place an image or text watermark anywhere on your images using the open source ImageProcessor library. The library provides full support for adding watermark to images with just few lines of code. The required class contains all the properties necessary to add the text based watermark to the image. It supports text color, select Font, Font Size, Style, opacity, position, drop-shadow and more.

Crop Images using .NET

The ImageProcessor gives software developers the ability to crops the current image to a custom location and size. Cropping is the most important yet easy process to consider when editing your images and photos. It provides several properties that help users to crop images according to their needs. Such as left, top, right, bottom and CropMode.

Crop Images using C# .NET


namespace ImageProcessor.Tests.Processing
{
    public class CropTests
    {
        private const string category = "Crop";

        [Fact]
        public void CropSettingsConstructorSetsOptions()
        {
            const int Left = 1;
            const int Top = 1;
            const int Right = 1;
            const int Bottom = 1;

            var expected = new CropOptions(Left, Top, Right, Bottom, CropMode.Percentage);

            Assert.Equal(expected.Left, Left);
            Assert.Equal(expected.Top, Top);
            Assert.Equal(expected.Right, Right);
            Assert.Equal(expected.Bottom, Bottom);
        }

        [Fact]
        public void CropSettingsConstructorChecksInput()
        {
            Assert.Throws(() => new CropOptions(-1, 0, 0, 0));
            Assert.Throws(() => new CropOptions(0, -1, 0, 0));
            Assert.Throws(() => new CropOptions(0, 0, -1, 0));
            Assert.Throws(() => new CropOptions(0, 0, 0, -1));
        }

        [Fact]
        public void CropConstructorSetsOptions()
        {
            var expected = new CropOptions(1, 2, 3, 4, CropMode.Percentage);
            var processor = new Crop(expected);

            Assert.Equal(expected, processor.Options);
        }

        [Fact]
        public void FactoryCanCropRectangle()
        {
            // Test our issue crop.
            TestFile file = TestFiles.Jpeg.EXIFCropIssue559;
            var bounds = new Rectangle(939, 439, 2778, 2778);
            using (var factory = new ImageFactory())
            {
                factory.Load(file.FullName)
                       .Crop(bounds)
                       .SaveAndCompare(file, category, bounds);
            }
        }

        [Fact]
        public void FactoryCanCropPercentile()
        {
            // Test our issue crop.
            TestFile file = TestFiles.Jpeg.Penguins;
            var settings = new CropOptions(15, 25, 10, 5, CropMode.Percentage);
            using (var factory = new ImageFactory())
            {
                factory.Load(file.FullName)
                       .Crop(settings)
                       .SaveAndCompare(file, category, settings);
            }
        }
    }
}            
 English