DotNetBrightener.UploadService.ImageOptimizer 2026.0.1

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package DotNetBrightener.UploadService.ImageOptimizer --version 2026.0.1
                    
NuGet\Install-Package DotNetBrightener.UploadService.ImageOptimizer -Version 2026.0.1
                    
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="DotNetBrightener.UploadService.ImageOptimizer" Version="2026.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotNetBrightener.UploadService.ImageOptimizer" Version="2026.0.1" />
                    
Directory.Packages.props
<PackageReference Include="DotNetBrightener.UploadService.ImageOptimizer" />
                    
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 DotNetBrightener.UploadService.ImageOptimizer --version 2026.0.1
                    
#r "nuget: DotNetBrightener.UploadService.ImageOptimizer, 2026.0.1"
                    
#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 DotNetBrightener.UploadService.ImageOptimizer@2026.0.1
                    
#: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=DotNetBrightener.UploadService.ImageOptimizer&version=2026.0.1
                    
Install as a Cake Addin
#tool nuget:?package=DotNetBrightener.UploadService.ImageOptimizer&version=2026.0.1
                    
Install as a Cake Tool

DotNetBrightener.UploadService.ImageOptimizer

Image optimization and resizing functionality for DotNetBrightener Upload Service.

๐Ÿ”’ Migration Notice - Version 2026.0.1+

Version 2026.0.1+ has migrated from Magick.NET to SkiaSharp due to security vulnerability CVE-2025-65955.

Security Details

  • Vulnerability: CVE-2025-65955 (CVSS 4.9/10 - Moderate)
  • Affected Package: Magick.NET v14.9.1
  • Issue: Use-after-free/double-free in ImageMagick's Magick++ layer
  • Resolution: Migrated to SkiaSharp (Microsoft-backed, actively maintained)

๐Ÿš€ Breaking Changes

Old Method (Deprecated)

services.AddUploadService(config)
    .UseImageMagickOptimizer(); // โš ๏ธ Deprecated - shows warning
services.AddUploadService(config)
    .UseSkiaSharpOptimizer(); // โœ… Use this instead

โœจ Benefits of SkiaSharp

  • โœ… No security vulnerabilities - Actively maintained by Microsoft
  • โœ… Better cross-platform support - Windows, Linux, macOS, iOS, Android
  • โœ… High performance - Native Skia graphics engine
  • โœ… Modern .NET API - Designed for .NET Core and beyond
  • โœ… Comprehensive graphics features - More than just image resizing

๐Ÿ“ฆ Installation

dotnet add package DotNetBrightener.UploadService.ImageOptimizer

๐Ÿ“– Usage

Basic Setup

using Microsoft.Extensions.DependencyInjection;

// In your Startup.cs or Program.cs
services.AddUploadService(configuration)
    .UseSkiaSharpOptimizer();

Advanced Configuration

services.AddUploadService(configuration)
    .UseSkiaSharpOptimizer()
    .ConfigureUploadOptions(options =>
    {
        options.MaxFileSize = 10 * 1024 * 1024; // 10MB
        options.AllowedFileExtensions = new[] { ".jpg", ".jpeg", ".png", ".gif", ".webp" };
    });

๐Ÿ”„ Migration Guide

Step 1: Update Package Reference

No changes needed if using centralized package management. The package will automatically use SkiaSharp.

Step 2: Update Code

Before:

services.AddUploadService(config)
    .UseImageMagickOptimizer();

After:

services.AddUploadService(config)
    .UseSkiaSharpOptimizer();

Step 3: Test Your Application

  1. Build your application
  2. Run unit tests
  3. Test image upload and resize functionality
  4. Verify image quality meets your requirements

Backward Compatibility

The old UseImageMagickOptimizer() method still works but:

  • Shows an [Obsolete] warning during compilation
  • Internally redirects to UseSkiaSharpOptimizer()
  • Will be removed in the next major version

๐Ÿ“ Supported Image Formats

SkiaSharp supports the following image formats:

  • PNG (default output format)
  • JPEG / JPG
  • GIF (including animated)
  • WebP
  • BMP
  • ICO
  • WBMP

๐Ÿ› ๏ธ API Reference

SkiaSharpImageOptimizer

public class SkiaSharpImageOptimizer : IImageResizer
{
    /// <summary>
    /// Resizes an image from the input stream to the specified dimensions
    /// </summary>
    /// <param name="inputStream">The input image stream</param>
    /// <param name="newWidth">The target width (absolute value will be used)</param>
    /// <param name="newHeight">The target height (absolute value will be used)</param>
    /// <returns>A new stream containing the resized image in PNG format</returns>
    Stream ResizeImageFromStream(Stream inputStream, int newWidth, int newHeight);
}

Extension Methods

// Recommended method
public static UploadServiceConfigurationBuilder UseSkiaSharpOptimizer(
    this UploadServiceConfigurationBuilder builder);

// Deprecated method (backward compatibility)
[Obsolete("Use UseSkiaSharpOptimizer instead")]
public static UploadServiceConfigurationBuilder UseImageMagickOptimizer(
    this UploadServiceConfigurationBuilder builder);

๐Ÿงช Testing

The package includes comprehensive unit tests:

  • Valid image resizing
  • Negative dimension handling (converts to absolute values)
  • Invalid stream handling
  • Various dimension scenarios
  • Large image handling
  • Output format verification (PNG)

To run tests:

cd src/UploadService/DotNetBrightener.UploadService.ImageOptimizer.Tests
dotnet test

๐Ÿ“Š Performance

SkiaSharp provides excellent performance characteristics:

  • High-quality resizing with SKFilterQuality.High
  • Native code execution via Skia engine
  • Efficient memory usage with proper disposal patterns
  • Cross-platform optimization for each OS

๐Ÿ› Troubleshooting

"Failed to decode image from input stream"

Cause: The input stream doesn't contain a valid image or format is not supported.

Solution: Verify the input stream contains valid image data and is in a supported format.

"Failed to resize image"

Cause: Invalid target dimensions or corrupted source image.

Solution: Ensure width and height are positive integers and source image is valid.


๐Ÿ”— Dependencies

  • SkiaSharp (3.119.1 or later) - Main graphics library
  • Microsoft.AspNetCore.App - Framework reference
  • DotNetBrightener.SimpleUploadService - Upload service abstractions

๐Ÿ“œ License

This package is part of the DotNetBrightener Framework.

ยฉ 2017 - 2025 Vampire Coder (formerly DotNet Brightener)


๐Ÿ†˜ Support

For issues, questions, or contributions:


๐Ÿ“š Additional 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
2026.0.2-preview-v2026-0-1-755 26 3/27/2026
2026.0.2-preview-758 0 3/29/2026
2026.0.2-preview-757 0 3/29/2026
2026.0.2-preview-756 37 3/27/2026
2026.0.2-preview-754 25 3/27/2026
2026.0.1 31 3/27/2026
2026.0.1-preview-temporal-s... 83 3/14/2026
2026.0.1-preview-752 29 3/26/2026
2026.0.1-preview-750 30 3/26/2026
2026.0.1-preview-749 49 3/25/2026
2026.0.1-preview-748 73 3/23/2026
2026.0.1-preview-742 70 3/22/2026
2026.0.1-preview-741 83 3/16/2026
2026.0.1-preview-737 78 3/9/2026
2026.0.1-preview-734 104 2/23/2026
2026.0.1-preview-733 93 2/6/2026
2026.0.1-preview-731 126 2/3/2026
2026.0.1-preview-728 108 1/20/2026
2026.0.1-preview-723 98 1/15/2026
2026.0.1-preview-721 101 1/15/2026
Loading failed