Skip to content

📷 A cross-platform library for the processing of image files; written in C#

Notifications You must be signed in to change notification settings

antonfirsov/ImageSharp

 
 

Repository files navigation

ImageSharp

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

ImageSharp is still in early stages (alpha) but progress has been pretty quick. As such, please do not use on production environments until the library reaches release candidate status. Pre-release downloads are available from the MyGet package repository.

GitHub license Build status GitHub issues GitHub stars GitHub forks ![Gitter](https://badges.gitter.im/Join Chat.svg) Twitter

Installation

At present the code is pre-release but when ready it will be available on Nuget.

Pre-release downloads

We already have a MyGet package repository - for bleeding-edge / development NuGet releases.

Manual build

If you prefer, you can compile ImageSharp yourself (please do and help!), you'll need:

To clone it locally click the "Clone in Windows" button above or run the following git commands.

git clone https://github.com/JimBobSquarePants/ImageSharp

What works so far/ What is planned?

  • Encoding/decoding of image formats (plugable).
  • Jpeg (Includes Subsampling. Progressive writing required)
  • Bmp (Read: 32bit, 24bit, 16 bit. Write: 32bit, 24bit just now)
  • Png (Read: Rgb, Rgba, Grayscale, Grayscale + alpha, Palette. Write: Rgb, Rgba, Grayscale, Grayscale + alpha, Palette) Needs interlaced decoding
  • Gif (Includes animated)
  • Tiff
  • Metadata
  • EXIF Read/Write (Jpeg just now)
  • Quantizers (IQuantizer with alpha channel support + thresholding)
  • Octree
  • Xiaolin Wu
  • Palette
  • Basic color structs with implicit operators.
  • Color - 32bit color in RGBA order (IPackedPixel<TPacked>).
  • Bgra32
  • CIE Lab
  • CIE XYZ
  • CMYK
  • HSV
  • HSL
  • YCbCr
  • IPackedPixel<TPacked> representations of color models. Compatible with Microsoft XNA Game Studio and MonoGame.
  • Alpha8
  • Argb
  • Bgr565
  • Bgra444
  • Bgra565
  • Byte4
  • HalfSingle
  • HalfVector2
  • HalfVector4
  • NormalizedByte2
  • NormalizedByte4
  • NormalizedShort2
  • NormalizedShort4
  • Rg32
  • Rgba1010102
  • Rgba64
  • Short2
  • Short4
  • Basic shape primitives.
  • Rectangle
  • Size
  • Point
  • Ellipse
  • Resampling algorithms. (Optional gamma correction, resize modes, Performance improvements?)
  • Box
  • Bicubic
  • Lanczos2
  • Lanczos3
  • Lanczos5
  • Lanczos8
  • MitchelNetravali
  • Nearest Neighbour
  • Robidoux
  • Robidoux Sharp
  • Spline
  • Triangle
  • Welch
  • Padding
  • Pad
  • ResizeMode.Pad
  • ResizeMode.BoxPad
  • Cropping
  • Rectangular Crop
  • Elliptical Crop
  • Entropy Crop
  • ResizeMode.Crop
  • Rotation/Skew
  • Flip (90, 270, FlipType etc)
  • Rotate by angle and center point (Expandable canvas).
  • Skew by x/y angles and center point (Expandable canvas).
  • ColorMatrix operations (Uses Matrix4x4)
  • BlackWhite
  • Grayscale BT709
  • Grayscale BT601
  • Hue
  • Saturation
  • Lomograph
  • Polaroid
  • Kodachrome
  • Sepia
  • Achromatomaly
  • Achromatopsia
  • Deuteranomaly
  • Deuteranopia
  • Protanomaly
  • Protanopia
  • Tritanomaly
  • Tritanopia
  • Edge Detection
  • Kayyali
  • Kirsch
  • Laplacian3X3
  • Laplacian5X5
  • LaplacianOfGaussian
  • Prewitt
  • RobertsCross
  • Robinson
  • Scharr
  • Sobel
  • Blurring/Sharpening
  • Gaussian blur
  • Gaussian sharpening
  • Box Blur
  • Filters
  • Alpha
  • Contrast
  • Invert
  • BackgroundColor
  • Brightness
  • Pixelate
  • Mask
  • Oil Painting
  • Vignette
  • Glow
  • Threshold
  • Drawing
  • Image brush
  • Pattern brush
  • Solid brush
  • Hatch brush (Partial copy of System.Drawing brushes)
  • Pen (Solid, Dash, Custom)
  • Line drawing
  • Complex Polygons (Fill, draw)
  • DrawImage
  • Gradient brush (Need help)
  • Other stuff I haven't thought of.

What might never happen

  • Font support. I don't know where to start coding this so if you have any pointers please chip in.

API

Without the constraints of System.Drawing I 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. Images and processors are thread safe usable in parallel processing utilizing all the availables cores.

Many Image methods are also fluent.

Here's an example of the code required to resize an image using the default Bicubic resampler then turn the colors into their grayscale equivalent using the BT709 standard matrix.

using (FileStream stream = File.OpenRead("foo.jpg"))
using (FileStream output = File.OpenWrite("bar.jpg"))
{
    Image image = new Image(stream);
    image.Resize(image.Width / 2, image.Height / 2)
         .Grayscale()
         .Save(output);
}

Individual processors can be initialised and apply processing against images. This allows nesting which brings the potential for powerful combinations of processing methods:

new BrightnessProcessor(50).Apply(sourceImage, sourceImage.Bounds);

Setting individual pixel values is perfomed as follows:

Image image = new Image(400, 400);
using (PixelAccessor pixels = image.Lock())
{
    pixels[200, 200] = Color.White;
}

For advanced usage the Image<TColor, TPacked> and PixelAccessor<TColor, TPacked> classes are available allowing developers to implement their own color models in the same manner as Microsoft XNA Game Studio and MonoGame.

All in all this should allow image processing to be much more accessible to developers which has always been my goal from the start.

How can you help?

Please... Spread the word, contribute algorithms, submit performance improvements, unit tests.

Performance is a biggie, if you know anything about the new vector types and can apply some fancy new stuff with that it would be awesome.

There's a lot of developers out there who could write this stuff a lot better and faster than I and I would love to see what we collectively can come up with so please, if you can help in any way it would be most welcome and benificial for all.

The ImageSharp Team

Grand High Eternal Dictator

Core Team

About

📷 A cross-platform library for the processing of image files; written in C#

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.9%
  • Other 0.1%