LegioSoft.Imaging.Core 1.0.0-beta2

Prefix Reserved
This is a prerelease version of LegioSoft.Imaging.Core.
There is a newer version of this package available.
See the version list below for details.
dotnet add package LegioSoft.Imaging.Core --version 1.0.0-beta2
                    
NuGet\Install-Package LegioSoft.Imaging.Core -Version 1.0.0-beta2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LegioSoft.Imaging.Core" Version="1.0.0-beta2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LegioSoft.Imaging.Core" Version="1.0.0-beta2" />
                    
Directory.Packages.props
<PackageReference Include="LegioSoft.Imaging.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LegioSoft.Imaging.Core --version 1.0.0-beta2
                    
#r "nuget: LegioSoft.Imaging.Core, 1.0.0-beta2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LegioSoft.Imaging.Core@1.0.0-beta2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LegioSoft.Imaging.Core&version=1.0.0-beta2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=LegioSoft.Imaging.Core&version=1.0.0-beta2&prerelease
                    
Install as a Cake Tool

LegioSoft.Imaging

Modular .NET image processing library with unified API. Lightweight WebP support for simple use cases, or full-featured image processing with SkiaSharp for advanced operations.

Installation

Install all packages at once:

dotnet add package LegioSoft.Imaging

Or via NuGet Package Manager Console:

Install-Package LegioSoft.Imaging

Individual Packages

Lightweight WebP Only (~500KB):

dotnet add package LegioSoft.Imaging.Core
dotnet add package LegioSoft.Imaging.WebP

Full Image Processing (~5MB):

dotnet add package LegioSoft.Imaging.Core
dotnet add package LegioSoft.Imaging.Skia

Supported Frameworks: .NET 6.0, 7.0, 8.0, 9.0, 10.0

Quick Start

Basic Image Processing

Resize, crop, rotate, and save in one fluent chain:

using LegioSoft.Imaging.Skia;

// Simple resize
LegioImageBuilder.Load("photo.jpg")
    .Resize(800, 600)
    .Save("resized.jpg");

// Multiple operations
var result = LegioImageBuilder.Load("image.png")
    .Resize(1920, 1080, LegioScaleMode.Fit)
    .Crop(100, 100, 400, 400)
    .Rotate(90)
    .Grayscale()
    .Save("processed.jpg", quality: 90);

Format Conversion

Convert between PNG, JPEG, WebP, BMP, and GIF:

// PNG to WebP with quality control
var webpData = LegioImageBuilder.Load("image.png")
    .SaveAs(LegioImageFormat.WebP, quality: 85);

// JPEG to PNG (lossless)
LegioImageBuilder.Load("photo.jpg")
    .Save("photo.png");

Image Information

Get image metadata:

var info = LegioImageBuilder.Load("image.jpg").GetInfo();

Console.WriteLine($"Dimensions: {info.Width}x{info.Height}");
Console.WriteLine($"Format: {info.Format}");
Console.WriteLine($"Has Alpha: {info.HasAlpha}");
Console.WriteLine($"Size: {info.ByteSize} bytes");

Fluent Builder API

The LegioImageBuilder provides a fluent, chainable API for image operations:

Load

// From file path
var builder = LegioImageBuilder.Load("image.jpg");

// From byte array
var imageData = File.ReadAllBytes("image.jpg");
var builder = LegioImageBuilder.Load(imageData);

// From stream
using var stream = File.OpenRead("image.jpg");
var builder = LegioImageBuilder.Load(stream);

Resize

// Exact dimensions
.Resize(800, 600)

// Scale mode
.Resize(800, 600, LegioScaleMode.Fit)   // Fit within bounds
.Resize(800, 600, LegioScaleMode.Fill)  // Fill and crop
.Resize(800, 600, LegioScaleMode.Stretch) // Stretch to fit

// Resize to width only (maintains aspect ratio)
.ResizeToWidth(1200)

// Resize to height only (maintains aspect ratio)
.ResizeToHeight(800)

// Scale by factor
.Scale(0.5)  // 50% of original size
.Scale(2.0)  // 200% of original size

// Quality control
.Resize(800, 600, quality: LegioResizeQuality.High)

Crop

// Crop from (x, y) with width and height
.Crop(100, 100, 400, 400)

Transform

// Rotate (90, 180, or 270 degrees)
.Rotate(90)
.Rotate(180)
.Rotate(270)

// Flip
.Flip(horizontal: true, vertical: false)  // Horizontal flip
.Flip(horizontal: false, vertical: true)  // Vertical flip
.Flip(true, true)                        // Both

Filters

// Grayscale
.Grayscale()

// Sepia tone
.Sepia()

// Blur (radius 1-20, default 5)
.Blur()
.Blur(10)

// Sharpen (amount 0-100, default 50)
.Sharpen()
.Sharpen(70)

Color Adjustments

// Brightness (-255 to 255)
.Brightness(50)   // Lighten
.Brightness(-50)  // Darken

// Contrast (-100 to 100)
.Contrast(30)
.Contrast(-20)

// Invert colors
.Invert()

Save

// Save with detected format
.Save("output.jpg")

// Save with specific format
.Save("output.png", LegioImageFormat.Png)

// Save with quality (0-100, for lossy formats)
.Save("output.jpg", quality: 85)

// Save as byte array
var jpegData = SaveAs(LegioImageFormat.Jpeg, quality: 90);
var webpData = SaveAs(LegioImageFormat.WebP, quality: 80);

// Save as stream
using var stream = SaveAsStream(LegioImageFormat.Png);

Complete Examples

WebP Optimization

// Convert to WebP for web use
var optimized = LegioImageBuilder.Load("large-photo.jpg")
    .ResizeToWidth(1920)
    .Quality(85)
    .SaveAs(LegioImageFormat.WebP);

File.WriteAllBytes("optimized.webp", optimized);

Thumbnail Generation

// Generate thumbnail maintaining aspect ratio
LegioImageBuilder.Load("image.jpg")
    .Resize(300, 300, LegioScaleMode.Fit)
    .Quality(80)
    .Save("thumbnail.jpg");

Image Enhancement

// Enhance photo with multiple adjustments
LegioImageBuilder.Load("dark-photo.jpg")
    .Brightness(30)
    .Contrast(20)
    .Sharpen(60)
    .Blur(1)
    .Save("enhanced.jpg", quality: 90);

Batch Processing

// Process all images in directory
var inputFiles = Directory.GetFiles("input", "*.jpg");

foreach (var file in inputFiles)
{
    var fileName = Path.GetFileNameWithoutExtension(file);
    var outputPath = Path.Combine("output", $"{fileName}.png");

    LegioImageBuilder.Load(file)
        .Resize(1920, 1080, LegioScaleMode.Fit)
        .Quality(90)
        .Save(outputPath, LegioImageFormat.Png);
}

Profile Picture Processing

// Create square profile picture from any image
var processed = LegioImageBuilder.Load("profile-photo.jpg")
    .Resize(500, 500, LegioScaleMode.Fill)  // Square
    .Brightness(10)
    .Contrast(15)
    .SaveAs(LegioImageFormat.Jpeg, quality: 85);

Watermark Effect

// Apply subtle blur for watermark effect
LegioImageBuilder.Load("product.jpg")
    .Resize(1200, 800)
    .Blur(2)
    .Grayscale()
    .Save("watermark-preview.jpg");

Package Structure

LegioSoft.Imaging.Core

Lightweight core package with interfaces, enums, and base types.

  • ILegioImageEncoder - Encode images
  • ILegioImageDecoder - Decode and get metadata
  • ILegioImageResizer - Resize operations
  • ILegioImageCropper - Crop operations
  • ILegioImageTransformer - Rotate/flip operations
  • ILegioImageFilter - Filter operations
  • LegioImageFormat - PNG, JPEG, WebP, BMP, GIF
  • LegioScaleMode - Fit, Fill, Stretch
  • LegioResizeQuality - Low, Medium, High, Maximum
  • LegioImageInfo - Image metadata

LegioSoft.Imaging.WebP

Lightweight WebP codec using native libwebp.

  • Implements ILegioImageEncoder and ILegioImageDecoder
  • Native libraries for Windows x64, Linux x64, Linux ARM64
  • No SkiaSharp dependency
  • ~500KB package size

LegioSoft.Imaging.Skia

Full-featured image processing with SkiaSharp.

  • Implements all core interfaces
  • Fluent builder API (LegioImageBuilder)
  • Resize, crop, rotate, flip
  • Filters: grayscale, sepia, blur, sharpen
  • Color adjustments: brightness, contrast, invert
  • Format conversion
  • Cross-platform (Windows, macOS, Linux)
  • ~5MB package size

LegioSoft.Imaging

Meta package that includes all components.

  • All-in-one installation
  • Core + WebP + SkiaSharp
  • ~5.5MB package size

Supported Formats

Input Formats: PNG, JPEG, WebP, BMP, GIF

Output Formats:

  • PNG - Lossless, supports transparency
  • JPEG - Lossy, best for photos
  • WebP - Modern format, good compression
  • BMP - Uncompressed, Windows bitmap
  • GIF - Limited color, simple animation support

Performance Tips

  • Use ResizeToWidth or ResizeToHeight to maintain aspect ratio without extra calculations
  • Batch operations in one builder chain to avoid loading image multiple times
  • Use appropriate quality settings (70-85 for JPEG, 80-90 for WebP)
  • Prefer WebP for web use (better compression than JPEG at similar quality)

Platform Support

  • Windows: x64
  • Linux: x64, ARM64
  • macOS: x64, ARM64 (via SkiaSharp)

Dependencies

Core Package: No external dependencies

WebP Package:

  • LegioSoft.Imaging.Core
  • Native libwebp libraries (included)

Skia Package:

  • LegioSoft.Imaging.Core
  • SkiaSharp 2.88.6
  • Platform-specific SkiaSharp native assets

License

Apache License 2.0

Repository

https://github.com/legiosoft/legiosoft-imaging

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on LegioSoft.Imaging.Core:

Package Downloads
LegioSoft.Imaging.Skia

Full-featured image processing library built on SkiaSharp. Implements ILegioImageResizer, ILegioImageCropper, ILegioImageTransformer, and ILegioImageFilter interfaces. Provides fluent builder API for easy image manipulation. Supports resize, crop, rotate, flip, and filters (grayscale, sepia, blur, sharpen, brightness, contrast, invert). Format conversion for PNG, JPEG, and WebP. Cross-platform support for Windows, macOS, and Linux. Supports .NET 6.0, 7.0, 8.0, 9.0, and 10.0.

LegioSoft.Imaging.WebP

WebP codec wrapper using native libwebp v1.6.0. High-performance WebP encoding and decoding with support for RGBA, RGB, BGRA, BGR formats. Features include lossless/lossy compression, scaling, cropping, flip, and advanced encoding options. Updated for libwebp 1.6.0 with correct ABI version (0x0210) and proper memory management (WebPMemoryWriterClear). Cross-platform support (Windows, Linux, macOS). Implements ILegioImageEncoder and ILegioImageDecoder interfaces from Core package. Use FormatDetector from Core for format detection.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 224 3/9/2026
1.0.0 399 1/16/2026
1.0.0-beta3 134 1/10/2026
1.0.0-beta2 105 1/9/2026
1.0.0-beta1 110 1/9/2026

1.0.0-beta2 - Initial beta release of LegioSoft.Imaging.Core.

     Features:
     - ILegioImageEncoder and ILegioImageDecoder interfaces for encoding/decoding
     - ILegioImageResizer for resize operations
     - ILegioImageCropper for crop operations
     - ILegioImageTransformer for rotate/flip operations
     - ILegioImageFilter for filter operations (grayscale, sepia, blur, sharpen)
     - LegioImageFormat enum (PNG, JPEG, WebP, BMP, GIF)
     - LegioScaleMode enum (Fit, Fill, Stretch)
     - LegioResizeQuality enum (Low, Medium, High, Maximum)
     - LegioEncodingQuality enum (0-100 quality levels)
     - LegioImageInfo class for image metadata
     - Support for .NET 6.0, 7.0, 8.0, 9.0, and 10.0