Recursive AI
LibraryC#Available

oneimage

An image library for .NET, written from scratch in C# with no dependency beyond .NET itself. One-line thumbnails, crops and conversions, on a lazy, tiled engine.

dotnet add package RecursiveAI.OneImage

A quick look

Operations only record what to do. Pixels are computed tile by tile when you save, so a 24 MP photo becomes a thumbnail without ever being held at full size.

Read the guide
Program.csC#
using OneImage;
 
// 400 px thumbnail, upright, no GPS.
Image.Thumbnail("in.jpg", 400)
    .Save("thumb.webp");
 
// Nothing is decoded until Save.
Image.Load("in.jpg")
    .Resize(width: 1200)
    .Rotate(90)
    .Save("out.png");
What it does

What it does

Lazy, tiled and streaming

Resize, crop and the rest are applied tile by tile on save. JPEGs decode at 1/2, 1/4 or 1/8 scale when that is enough.

One-liners and a canvas

Image.Thumbnail for the common job; an immutable Image pipeline and a mutable tiled Canvas when you need to edit pixels.

Color and metadata

ICC v2 and v4 profiles, CMYK to sRGB and resampling in linear light. EXIF orientation is applied for you, and thumbnails strip GPS by default.

Safe on files you didn’t write

Parsers and decoders are bounds-checked C#, and every decoder is fuzzed. Size limits are on by default and checked from headers before anything large is allocated.

Performance

Faster than ImageSharp on most tasks

Against ImageSharp 3.1.12, oneimage is faster on every benchmark task but two. Watermarking is a tie. CMYK JPEG to sRGB is 1.64× slower, because ImageSharp skips the ICC conversion that oneimage applies.

Native wrappers win some tasks: NetVips is about 3× faster on multi-page TIFF reads and ahead on JPEG encoding and one PNG encode input, and SkiaSharp decodes GIFs faster. A JPEG thumbnail uses about 1 MiB more peak memory than ImageSharp.

Every result and the method
How many times faster oneimage is than ImageSharp 3.1.12, per task

Wall-clock time, log scale, longer is better. Bars left of 1× are slower; the hatched bar is the one slower task.

  1. thumb-jpeg 1.25×
  2. thumb-webp 1.39×
  3. png-to-webp (natural) 19.1×
  4. png-to-webp (photo) 11.3×
  5. png-to-webp (screenshot) 2.5×
  6. jpeg-decode 1.9×
  7. jpeg-encode 1.15×
  8. png-decode (natural) 3.4×
  9. png-decode (photo) 1.21×
  10. png-decode (screenshot) 1.45×
  11. png-encode (natural) 4.8×
  12. png-encode (photo) 6.1×
  13. png-encode (screenshot) 1.9×
  14. webp-decode (lossy) 1.8×
  15. webp-decode (lossless) 2.7×
  16. webp-encode (lossless 2000×1500) 7.5×
  17. webp-encode (lossy 2000×1500) 5.8×
  18. webp-encode (lossy 400×300) 4.4×
  19. gif-decode 2.7×
  20. gif-encode 1.26×
  21. gif-resize 1.17×
  22. tiff-multipage-decode 7.0×
  23. tiff-encode 3.0×
  24. bmp-decode 1.8×
  25. bmp-encode 1.8×
  26. upscale-2x 2.0×
  27. watermark 1.00× tie
  28. cmyk-jpeg-to-srgb 0.61× slower
  29. jpeg-decode-rgba 1.8×

Measured with BenchmarkDotNet on one shared workstation. Local measurements, not promises for your hardware.

The package

Go further