Convert Figma logo to code with AI

SixLabors logoImageSharp

:camera: A modern, cross-platform, 2D Graphics library for .NET

7,735
879
7,735
38

Top Related Projects

SkiaSharp is a cross-platform 2D graphics API for .NET platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.

:camera: A fluent wrapper around System.Drawing for the processing of image files.

High-performance image manipulation for web servers. Includes imageflow_server, imageflow_tool, and libimageflow

ImageMagick is a free, open-source software suite for creating, editing, converting, and displaying images. It supports 200+ formats and offers powerful command-line tools and APIs for automation, scripting, and integration across platforms.

Quick Overview

ImageSharp is a cross-platform 2D graphics library for .NET. It provides a comprehensive set of image processing operations and supports loading, saving, and manipulating images in various formats. The library is designed to be fast, flexible, and extensible, making it suitable for a wide range of image processing tasks.

Pros

  • Cross-platform compatibility (works on Windows, macOS, and Linux)
  • High performance and memory-efficient image processing
  • Supports a wide range of image formats
  • Actively maintained and well-documented

Cons

  • Relatively new compared to established libraries like System.Drawing
  • Some advanced features may require additional plugins or extensions
  • Learning curve for developers new to image processing concepts

Code Examples

Loading and resizing an image:

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;

using (Image image = Image.Load("input.jpg"))
{
    image.Mutate(x => x.Resize(800, 600));
    image.Save("output.jpg");
}

Applying multiple image processing operations:

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;

using (Image image = Image.Load("input.png"))
{
    image.Mutate(x => x
        .Resize(400, 300)
        .Grayscale()
        .GaussianBlur(5));
    image.Save("output.png");
}

Drawing shapes and text on an image:

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.Processing;
using SixLabors.Fonts;

using (Image image = new Image<Rgba32>(400, 300))
{
    var font = SystemFonts.CreateFont("Arial", 24);
    image.Mutate(x => x
        .Fill(Color.LightBlue)
        .DrawCircle(Color.Red, 5, new PointF(100, 100), 50)
        .DrawText("Hello, ImageSharp!", font, Color.Black, new PointF(50, 50)));
    image.Save("output.png");
}

Getting Started

  1. Install the NuGet package:

    dotnet add package SixLabors.ImageSharp
    
  2. Add the necessary using statements:

    using SixLabors.ImageSharp;
    using SixLabors.ImageSharp.Processing;
    
  3. Use the library in your code:

    using (Image image = Image.Load("input.jpg"))
    {
        image.Mutate(x => x.Resize(new ResizeOptions
        {
            Size = new Size(800, 600),
            Mode = ResizeMode.Max
        }));
        image.Save("output.jpg");
    }
    

This example loads an image, resizes it to fit within 800x600 pixels while maintaining its aspect ratio, and saves the result.

Competitor Comparisons

SkiaSharp is a cross-platform 2D graphics API for .NET platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.

Pros of SkiaSharp

  • Backed by Google's Skia graphics engine, offering high performance and cross-platform support
  • Extensive API with more advanced features for complex graphics operations
  • Supports hardware acceleration on multiple platforms

Cons of SkiaSharp

  • Larger library size due to native dependencies
  • Steeper learning curve for beginners
  • May require platform-specific configurations for optimal performance

Code Comparison

SkiaSharp:

using SkiaSharp;

using (var surface = SKSurface.Create(new SKImageInfo(width, height)))
{
    var canvas = surface.Canvas;
    canvas.DrawCircle(100, 100, 50, new SKPaint { Color = SKColors.Blue });
}

ImageSharp:

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Drawing.Processing;

using (var image = new Image<Rgba32>(width, height))
{
    image.Mutate(x => x.DrawCircle(Color.Blue, 50, new PointF(100, 100)));
}

Both libraries offer similar functionality for basic image processing tasks. SkiaSharp provides a lower-level API with more control over drawing operations, while ImageSharp offers a more intuitive API for common image manipulation tasks. SkiaSharp is better suited for complex graphics applications, while ImageSharp is ideal for simpler image processing needs in a pure .NET environment.

:camera: A fluent wrapper around System.Drawing for the processing of image files.

Pros of ImageProcessor

  • Mature and stable project with a longer history
  • Supports GDI+ and System.Drawing, which may be beneficial for legacy .NET Framework projects
  • Extensive documentation and community support

Cons of ImageProcessor

  • Limited cross-platform support compared to ImageSharp
  • Less active development and fewer recent updates
  • Performance may be slower for certain operations, especially on non-Windows platforms

Code Comparison

ImageProcessor:

using (var imageFactory = new ImageFactory(preserveExifData: true))
{
    imageFactory.Load(inputPath)
                .Resize(new Size(150, 0))
                .Save(outputPath);
}

ImageSharp:

using (Image image = Image.Load(inputPath))
{
    image.Mutate(x => x.Resize(new ResizeOptions { Size = new Size(150, 0) }));
    image.Save(outputPath);
}

Both libraries offer similar functionality for basic image processing tasks. However, ImageSharp's API is more modern and flexible, with better support for asynchronous operations and cross-platform development. ImageProcessor may be more suitable for projects that require compatibility with older .NET Framework versions or specific GDI+ features.

High-performance image manipulation for web servers. Includes imageflow_server, imageflow_tool, and libimageflow

Pros of Imageflow

  • Faster performance, especially for large images and high-volume processing
  • Supports a wider range of image formats, including WebP and JPEG-XR
  • Provides a REST API for easy integration with web applications

Cons of Imageflow

  • Less active community and fewer contributors compared to ImageSharp
  • More complex setup and configuration process
  • Limited cross-platform support (primarily focused on Windows and Linux)

Code Comparison

ImageSharp:

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;

using (Image image = Image.Load("input.jpg"))
{
    image.Mutate(x => x.Resize(800, 600));
    image.Save("output.jpg");
}

Imageflow:

using Imageflow.Fluent;

using (var job = new FluentBuildJob())
{
    job.Decode("input.jpg")
       .Constrain(new Constraint(800, 600))
       .EncodeToBytes(new JpegEncoder())
       .Save("output.jpg");
    await job.FinishAsync();
}

Both libraries offer similar functionality for basic image processing tasks. ImageSharp provides a more intuitive API for .NET developers, while Imageflow focuses on performance and advanced features. The choice between the two depends on specific project requirements, performance needs, and desired level of community support.

ImageMagick is a free, open-source software suite for creating, editing, converting, and displaying images. It supports 200+ formats and offers powerful command-line tools and APIs for automation, scripting, and integration across platforms.

Pros of ImageMagick

  • Extensive feature set with support for over 200 image formats
  • Robust command-line interface for batch processing
  • Long-standing project with a large community and extensive documentation

Cons of ImageMagick

  • Steeper learning curve due to its complexity
  • Larger footprint and potential performance overhead
  • Requires external dependencies and native bindings

Code Comparison

ImageMagick (C#):

using ImageMagick;

using (var image = new MagickImage("input.jpg"))
{
    image.Resize(300, 200);
    image.Write("output.jpg");
}

ImageSharp:

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;

using (var image = Image.Load("input.jpg"))
{
    image.Mutate(x => x.Resize(300, 200));
    image.Save("output.jpg");
}

Summary

ImageMagick offers a comprehensive set of features and broad format support, making it suitable for complex image processing tasks. However, it comes with a steeper learning curve and potential performance overhead. ImageSharp, on the other hand, provides a more lightweight and modern approach, focusing on .NET Core compatibility and ease of use. The choice between the two depends on specific project requirements, performance needs, and developer preferences.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

SixLabors.ImageSharp
SixLabors.ImageSharp

Build Status Code coverage License: Six Labors Split Twitter

ImageSharp is a new, fully featured, fully managed, cross-platform, 2D graphics API.

ImageSharp is a new, fully featured, fully managed, cross-platform, 2D graphics library. Designed to simplify image processing, ImageSharp brings you an incredibly powerful yet beautifully simple API.

ImageSharp is designed from the ground up to be flexible and extensible. The library provides API endpoints for common image processing operations and the building blocks to allow for the development of additional operations.

Built against .NET 8, ImageSharp can be used in device, cloud, and embedded/IoT scenarios.

License

Support Six Labors

Support the efforts of the development of the Six Labors projects.

Documentation

  • Detailed documentation for the ImageSharp API is available. This includes additional conceptual documentation to help you get started.
  • Our Samples Repository is also available containing buildable code samples demonstrating common activities.

Questions

Code of Conduct

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information, see the .NET Foundation Code of Conduct.

Installation

Install stable releases via Nuget; development releases are available via MyGet.

Package NameRelease (NuGet)Nightly (Feedz.io)
SixLabors.ImageSharpNuGetfeedz.io

Manual build

If you prefer, you can compile ImageSharp yourself (please do and help!)

Alternatively, you can work from command line and/or with a lightweight editor on both Linux/Unix and Windows:

To clone ImageSharp locally, click the "Clone in [YOUR_OS]" button above or run the following git commands:

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

Then set the following config to ensure blame commands ignore mass reformatting commits.

git config blame.ignoreRevsFile .git-blame-ignore-revs

If working with Windows please ensure that you have enabled long file paths in git (run as Administrator).

git config --system core.longpaths true

This repository uses Git Large File Storage. Please follow the linked instructions to ensure you have it set up in your environment.

This repository contains Git Submodules. To add the submodules to the project, navigate to the repository root and type:

git submodule update --init --recursive

How can you help?

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.

Useful tools for development and links to specifications can be found in our wikipage: Useful-tools-and-links.

The ImageSharp Team


JetBrains

Special thanks to JetBrains for supporting us with open-source licenses for their IDEs.