Skip to content

About

Pure managed .NET image library: tiled, demand-driven engine; PNG, JPEG, WebP, GIF, TIFF, BMP, ICO codecs and ICC color management written from the specs, with no native dependencies.

Resources

Code of conduct

Contributing

Security policy

Stars

14 stars

Watchers

0 watching

Forks

OneImage

A pure-managed .NET image library: one-line thumbnails, crops and conversions, and lazy, tiled, streaming load, edit and render on the same engine. PNG, JPEG, WebP, GIF, TIFF, BMP and ICO, with ICC color management. Pure C# with no dependency beyond .NET itself; untrusted files are read through bounds-checked managed code.

NuGet CI .NET 10 License

How many times faster OneImage is than ImageSharp 3.1.12 on each benchmark task (wall-clock time, log scale, higher is better; a task where OneImage is slower shows as a bar to the left, a tie in gray):

Bar chart: how many times faster OneImage is than ImageSharp on each benchmark task, log scale, higher is better. Almost every bar is a win; one task is a tie and one, where ImageSharp skips the ICC color conversion, is slower.

Full results, with memory, the losses and the method →

Why OneImage

  • Lazy, tiled and streaming. Resize, Crop and the other operations only record what to do. Pixels are computed tile by tile when you save, so a 24 MP photo becomes a thumbnail without being held at full size, and JPEGs decode at 1/2, 1/4 or 1/8 scale when that is enough (guide).
  • One-liners and an editing surface. Image.Thumbnail(...) for the common job; an immutable Image pipeline and a mutable tiled Canvas with O(1) snapshots when you need to edit pixels (guide).
  • Color and metadata done right. ICC v2/v4 profiles, CMYK to sRGB, resampling in linear light, EXIF orientation applied for you, and thumbnails that strip GPS by default (color, metadata).
  • Safe on files you did not write. Parsers and decoders are bounds-checked C#; the only unsafe code is in SIMD kernels that run on already-validated buffers. Size limits are on by default and checked from headers before anything large is allocated; every decoder is fuzzed (limits, fuzzing). NativeAOT and trimming are supported.
  • Fast, with the losses shown. Faster than ImageSharp on every benchmark task except one tie and one CMYK task where ImageSharp skips the ICC conversion, and with less peak memory on most. Not on all: a JPEG thumbnail uses about 1 MiB more peak memory than ImageSharp, and NetVips is ahead on multi-page TIFF reads (about 3× at the default thread limit), on JPEG encoding and on one of the PNG encode inputs (every loss).

How OneImage compares with ImageSharp, SkiaSharp, Magick.NET and NetVips, including when one of them is the better choice.

Install

dotnet add package RecursiveAI.OneImage

The package is RecursiveAI.OneImage; the namespace is OneImage (using OneImage;).

Target framework net10.0. Moving from ImageSharp or System.Drawing? See the migration guide.

Quick start

using OneImage;

// A 400 px wide thumbnail, upright, in sRGB, without EXIF/GPS, written as WebP.
Image.Thumbnail("in.jpg", 400).Save("thumb.webp");

// Load, edit, save. Nothing is decoded until Save.
Image.Load("in.jpg")
    .Resize(width: 1200)
    .Rotate(90)
    .Save("out.png");

// Format and quality.
Image.Load("in.png").Save("out.jpg", new SaveOptions { EncoderOptions = new JpegEncoderOptions { Quality = 85 } });

The format of Save follows the file extension. For streams and buffer writers, name it: image.Save(stream, PngFormat.Instance). Image is lazy and immutable; read the guide next for when errors appear, how sources are held, limits and threading.

Where to go

  • Using it: the guide (lazy model, errors, operations, Canvas, metadata, color, animation, limits, AOT and trimming, formats). The API reference is the XML documentation your IDE shows.
  • Migrating: from ImageSharp and System.Drawing.
  • Serving images from ASP.NET Core: OneImage.Web, URL-driven resizing with a disk cache, signed URLs and request limits.
  • Drawing and text: vector drawing (paths, fills, strokes, brushes, boolean operations, clipping) is in the core package; OneImage.Text adds fonts, OpenType shaping, line breaking, rich text and color glyphs.
  • Layered documents: layers (OneImage.Layers: pixel, group, fill and adjustment layers, masks, clipping, blend modes, render on demand with incremental re-rendering, and an optional disk-spill store) is in the core package.
  • Photoshop files: OneImage.Psd (RecursiveAI.OneImage.Psd) reads PSD and PSB as an image format (the merged composite) and loads the layer tree into a layers document, edits and writes it back. Photoshop's posterize, curves and brightness/contrast formulas are used, gradient and pattern fills are drawn from their settings, and common layer effects (shadows, glows, strokes, overlays, satin) are drawn; text, smart objects and the other effects are kept as their stored pixels plus untouched blocks, and multichannel documents are refused. Edited layer styles and fills are written back; the page lists what is modeled and the known limitations.
  • PDF pages: OneImage.Pdf (RecursiveAI.OneImage.Pdf) draws PDF pages as an image format, on demand per tile and at the size you ask for; parsing comes from OnePDF (RecursiveAI.OnePdf), and JPEG, JPEG 2000 and JBIG2 images are decoded by OneImage itself. The page describes how it is checked against the specification and lists the known limitations.
  • Windows metafiles: OneImage.Metafile (RecursiveAI.OneImage.Metafile) reads EMF, EMF+ and WMF as images drawn at the size you ask for, and exposes each picture as a documented stream of drawing commands for vector output. The page lists the records covered, how it compares with Windows GDI and GDI+ output, and the known gaps.
  • Reading SVG: OneImage.Svg (RecursiveAI.OneImage.Svg) registers SVG and .svgz as an image format that is drawn at the size you ask for; it depends on the core package and OneImage.Text.
  • Running in the browser: WebAssembly support: what runs sequentially there, the lower default memory limits, and what CI tests.
  • Choosing a library: how OneImage compares, including where the others win.
  • Evidence: benchmark tables (the numbers behind the chart, every loss and the method), fuzzing.
  • What changed: CHANGELOG.md.
  • Contributing and security: CONTRIBUTING.md, SECURITY.md, CODE_OF_CONDUCT.md.

License

Licensed under either of MIT or Apache-2.0 at your option.

Copyright (c) Recursive AI, LLC.

About

Pure managed .NET image library: tiled, demand-driven engine; PNG, JPEG, WebP, GIF, TIFF, BMP, ICO codecs and ICC color management written from the specs, with no native dependencies.

Resources

Code of conduct

Contributing

Security policy

Stars

14 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages