No System.Drawing? No Problem!

ImageSharp is a fully featured, fully managed, cross-platform, 2D graphics API designed to allow the processing of images without the use of System.Drawing.

Built against .Net Standard 1.1 ImageSharp can be used in device, cloud, and embedded/IoT scenarios.

Hosted on Github.

ImageSharp has made excellent progress and contains many great features but is still considered by us to be still in early stages (alpha). As such, we cannot support its use on production environments until the library reaches release candidate status.

Pre-release downloads are available from the MyGet package repository.

What's Included

ImageSharp

  • Contains the Image classes, Colors, Primitives, Configuration, and other core functionality.
  • The IImageFormat interface, Jpeg, Png, Bmp, and Gif formats.
  • Transform methods like Resize, Crop, Skew, Rotate - Anything that alters the dimensions of the image.
  • Non-transform methods like Gaussian Blur, Pixelate, Edge Detection - Anything that maintains the original image dimensions.

ImageSharp.Drawing

  • Brushes and various drawing algorithms, including drawing images.
  • Various vector drawing methods for drawing paths, polygons etc.
  • Text rendering.

A Better API

Without the constraints of System.Drawing We have been able to develop something much more flexible, easier to code against, and much, much less prone to memory leaks.

Gone are system-wide process-locks; ImageSharp images are thread-safe and fully supported in web environments.

Here's an example of the code required to load an image from a file, resize it, and save it back to the filesystem as a jpeg with a quality of 75.

System.Drawing

using (Image image = Image.FromFile("foo.jpg", true))
using (Bitmap resized = new Bitmap(image.Width / 2, image.Width / 2))
using (Graphics graphics = Graphics.FromImage(resized))
using (ImageAttributes attributes = new ImageAttributes())
{
    attributes.SetWrapMode(WrapMode.TileFlipXY);
    graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
    graphics.CompositingQuality = CompositingQuality.HighSpeed;
    graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
    graphics.CompositingMode = CompositingMode.SourceCopy;
    graphics.DrawImage(image, Rectangle.FromLTRB(0, 0, image.Width / 2, image.Width / 2), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attributes);

    using (EncoderParameters encoderParameters = new EncoderParameter(Encoder.Quality, 75))
    {
        ImageCodecInfo codec = ImageCodecInfo.GetImageEncoders()
                                             .FirstOrDefault(ici => ici=> ici.FormatID == ImageFormat.Jpeg.Guid));

        using (FileStream output = File.OpenWrite("bar.jpg"))
        {
            resized.Save(output, codec, encoderParameters);
        }
    }
}

ImageSharp .Net Standard 1.3+ *

* .NET Standard is the lowest version that supports the filesystem API. We can load/save from streams though from .NET Standard 1.1+.
using (Image image = Image.Load("foo.jpg"))
{
    image.MetaData.Quality = 75;

    image.Resize(image.Width / 2, image.Height / 2)
         .Save("bar.jpg"); // Automatic encoder selected based on extension.
}

For advanced usage a generic Image<TColor> class is available allowing developers to implement their own color models in the same manner as Microsoft XNA Game Studio and MonoGame.

Support ImageSharp

We've teamed up with Open Collective to allow transparent contribution, donation, and sponsorship of the project. Your support will allow us to create the best solution possible, contributing to meetup costs, office time, and materials. Please get involved!

Sponsors

Does your company use ImageSharp? Help keep the project bug-free and feature rich by sponsoring the project.

Backers

Love our work and community? Become a backer.