Designed to democratize image processing, ImageSharp brings you an incredibly powerful yet beautifully simple API.
Compared to 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.
Built against .Net Standard 1.1 ImageSharp can be used in device, cloud, and embedded/IoT scenarios.
For all SixLabors projects, including ImageSharp: https://sixlabors.github.io/docs/
Install stable releases via Nuget; development releases are available via MyGet.
Package Name | Release (NuGet) | Nightly (MyGet) |
---|---|---|
SixLabors.ImageSharp |
||
SixLabors.ImageSharp.Drawing |
The ImageSharp library is made up of multiple packages:
-
SixLabors.ImageSharp
- Contains the generic
Image<TPixel>
class, PixelFormats, 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.
- Contains the generic
-
SixLabors.ImageSharp.Drawing
- Brushes and various drawing algorithms, including drawing images.
- Various vector drawing methods for drawing paths, polygons etc.
- Text drawing.
Build Status | Code Coverage | |
---|---|---|
Linux/Mac | ||
Windows |
- Do you have questions? We are happy to help! Please join our gitter channel, or ask them on stackoverflow using the
ImageSharp
tag. Do not open issues for questions! - Please read our Contribution Guide before opening issues or pull requests!
Our API is designed to be simple to consume. 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.
On platforms supporting netstandard 1.3+
// Image.Load(string path) is a shortcut for our default type.
// Other pixel formats use Image.Load<TPixel>(string path))
using (Image<Rgba32> image = Image.Load("foo.jpg"))
{
image.Mutate(x => x
.Resize(image.Width / 2, image.Height / 2)
.Grayscale());
image.Save("bar.jpg"); // Automatic encoder selected based on extension.
}
On netstandard 1.1 - 1.2
// Image.Load(Stream stream) is a shortcut for our default type.
// Other pixel formats use Image.Load<TPixel>(Stream stream))
using (FileStream stream = File.OpenRead("foo.jpg"))
using (FileStream output = File.OpenWrite("bar.jpg"))
using (Image<Rgba32> image = Image.Load(stream))
{
image.Mutate(x => x
.Resize(image.Width / 2, image.Height / 2)
.Grayscale());
image.Save(output);
}
Setting individual pixel values can be performed as follows:
// Individual pixels
using (Image<Rgba32> image = new Image<Rgba32>(400, 400))
{
image[200, 200] = Rgba32.White;
}
Rgba32
is our default PixelFormat, equivalent to System.Drawing Color
. For advanced pixel format usage there are multiple PixelFormat implementations available allowing developers to implement their own color models in the same manner as Microsoft XNA Game Studio and MonoGame.
For more examples check out:
If you prefer, you can compile ImageSharp yourself (please do and help!), you'll need:
- Visual Studio 2017 (or above)
- The .NET Core SDK Installer - Non VSCode link.
Alternatively on Linux you can use:
To clone it locally click the "Clone in Windows" button above or run the following git commands.
git clone https://github.com/SixLabors/ImageSharp
Please... Spread the word, contribute algorithms, submit performance improvements, unit tests, no input is too little. Make sure to read our Contribution Guide before opening a PR.
Grand High Eternal Dictator
Core Team
Support us with a monthly donation and help us continue our activities. [Become a backer]
Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]