Kck.Documents.SkiaSharp 5.0.0

dotnet add package Kck.Documents.SkiaSharp --version 5.0.0
                    
NuGet\Install-Package Kck.Documents.SkiaSharp -Version 5.0.0
                    
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="Kck.Documents.SkiaSharp" Version="5.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Kck.Documents.SkiaSharp" Version="5.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Kck.Documents.SkiaSharp" />
                    
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 Kck.Documents.SkiaSharp --version 5.0.0
                    
#r "nuget: Kck.Documents.SkiaSharp, 5.0.0"
                    
#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 Kck.Documents.SkiaSharp@5.0.0
                    
#: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=Kck.Documents.SkiaSharp&version=5.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Kck.Documents.SkiaSharp&version=5.0.0
                    
Install as a Cake Tool

Kck.Documents.SkiaSharp

SkiaSharp-backed IImageProcessor for server-side image resizing, format conversion and dimension reading. SkiaSharp is MIT-licensed. This package replaces Kck.Documents.ImageSharp, which is removed in 5.0.

Linux: add SkiaSharp.NativeAssets.Linux.NoDependencies (glibc and musl/Alpine) to the application; on Windows and macOS the SkiaSharp package carries the native library.

dotnet add package SkiaSharp.NativeAssets.Linux.NoDependencies

Installation

dotnet add package Kck.Documents.SkiaSharp

Quick Start

using Kck.Documents.Abstractions;

// Program.cs
builder.Services.AddKckDocumentsSkiaSharp();

// Resize and convert an uploaded image
app.MapPost("/thumbnail", async (IFormFile file, IImageProcessor images, CancellationToken ct) =>
{
    await using var input = file.OpenReadStream();
    var webp = await images.ResizeAsync(input, new ImageProcessingOptions
    {
        Width = 200,
        Height = 200,
        OutputFormat = "webp",
        Quality = 85
    }, ct);
    return Results.File(webp, "image/webp");
}).DisableAntiforgery();

Formats

Formats
Input (decode) JPEG, PNG, WebP, GIF, BMP, ICO
Output (encode) jpeg (jpg), png, webp

An empty OutputFormat / ConvertFormatAsync target keeps the source format; a GIF, BMP or ICO source becomes JPEG. Any other name, including gif and bmp, throws NotSupportedException. A stream SkiaSharp cannot decode (for example TIFF) and truncated or corrupt image data throw InvalidDataException.

Options

ImageProcessingOptions (per call):

Property Description Default
Width / Height Target size in pixels. One side set (the other null or 0): the other follows the source ratio; neither set: the size is kept; negative throws ArgumentOutOfRangeException before the stream is read null
MaintainAspectRatio With both sides set: fit inside the box (scaling up or down) instead of stretching true
OutputFormat jpeg (jpg), png, webp; null keeps the source format null
Quality Encoder quality, clamped to 1-100 (JPEG, WebP; WebP 100 is lossless); PNG ignores it 80

SkiaSharpOptions (registration):

Property Description Default
MaxPixels Largest accepted image (width × height), for the source and for the resize target. Both are checked from the header before any pixel is decoded, so a decoder bomb or an oversized request is rejected with InvalidOperationException. Must be at least 1 50_000_000
builder.Services.AddKckDocumentsSkiaSharp(options => options.MaxPixels = 20_000_000);

Notes

  • GetDimensionsAsync reads only the image header (no pixels are decoded) and returns the displayed size (orientation applied, like the ResizeAsync output); MaxPixels does not apply to it, so it can check an image first.
  • Converting an image with transparency to JPEG fills the transparent areas with white.
  • EXIF orientation is applied: a photo stored rotated comes out upright (the rotation is baked into the pixels).
  • The output carries no metadata: EXIF (including GPS location) and the ICC profile are not copied. Pixels are converted to sRGB, so Display P3 or Adobe RGB sources keep their colours without an embedded profile.
  • A non-seekable stream (for example a request body) is fully buffered in memory first; limit the request body size (Kestrel MaxRequestBodySize, FormOptions.MultipartBodyLengthLimit).

Resources

Product Compatible and additional computed target framework versions.
.NET 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.0.0 99 11/2/2026