Vali-Blob.ImageSharp 1.0.0

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

Vali-Blob.ImageSharp

NuGet License: MIT .NET

Image processing middleware for Vali-Blob using SixLabors.ImageSharp.

Plugs into the Vali-Blob middleware pipeline and automatically resizes, converts, and optimizes images before they are stored via any Vali-Blob provider (AWS S3, Azure Blob, GCP, OCI, Supabase, Local). Optionally generates a thumbnail alongside the main upload — all in a single pipeline step.


Compatibility

Target Framework Supported
net6.0 Yes
net7.0 Yes
net8.0 Yes
net9.0 Yes

Installation

dotnet add package ValiBlob.Core
dotnet add package ValiBlob.ImageSharp

Registration

using ValiBlob.Core.DependencyInjection;
using ValiBlob.AWS.Extensions;
using ValiBlob.ImageSharp.Extensions;

builder.Services
    .AddValiBlob(opts => opts.DefaultProvider = "AWS")
    .UseAWS()
    .WithImageProcessing(opts =>
    {
        opts.MaxWidth     = 1920;
        opts.MaxHeight    = 1080;
        opts.JpegQuality  = 85;
        opts.OutputFormat = ImageOutputFormat.Jpeg;
    });

With thumbnail generation

builder.Services
    .AddValiBlob(opts => opts.DefaultProvider = "AWS")
    .UseAWS()
    .WithImageProcessing(opts =>
    {
        opts.MaxWidth     = 2048;
        opts.MaxHeight    = 2048;
        opts.JpegQuality  = 80;
        opts.OutputFormat = ImageOutputFormat.WebP;

        opts.Thumbnail = new ThumbnailOptions
        {
            Width  = 300,
            Height = 300,
            Suffix = "_thumb"  // stored as "uploads/photo_thumb.webp"
        };
    });

Combined with validation

builder.Services
    .AddValiBlob(opts => opts.DefaultProvider = "Azure")
    .UseAzure()
    .WithPipeline(p => p
        .UseValidation(v =>
        {
            v.AllowedExtensions = new[] { ".jpg", ".jpeg", ".png", ".webp", ".gif" };
            v.MaxFileSizeBytes  = 20 * 1024 * 1024; // 20 MB before processing
        })
    )
    .WithImageProcessing(opts =>
    {
        opts.MaxWidth     = 1920;
        opts.MaxHeight    = 1080;
        opts.JpegQuality  = 82;
        opts.OutputFormat = ImageOutputFormat.Jpeg;

        opts.Thumbnail = new ThumbnailOptions
        {
            Width  = 200,
            Height = 200,
            Suffix = "_sm"
        };
    });

Usage

Once registered, image processing is fully transparent — just upload normally:

public class PhotoService(IStorageProvider storage)
{
    public async Task<PhotoResult> UploadPhotoAsync(IFormFile file, string userId)
    {
        await using var stream = file.OpenReadStream();

        var result = await storage.UploadAsync(new UploadRequest
        {
            Path        = StoragePath.From("photos", userId, file.FileName),
            Content     = stream,
            ContentType = file.ContentType
        });

        if (!result.IsSuccess)
            throw new Exception(result.ErrorMessage);

        // Image was automatically resized + converted + thumbnail generated
        return new PhotoResult
        {
            Url          = result.Value!.Url,
            ThumbnailUrl = result.Value!.ThumbnailUrl  // populated when opts.Thumbnail is set
        };
    }
}

How the pipeline works

Client upload (original JPEG, 8 MB, 4000×3000)
        │
        ▼
┌───────────────────────┐
│  ValidationMiddleware  │  ← reject if wrong extension / too large
└───────────┬───────────┘
            │
            ▼
┌───────────────────────┐
│  ImageSharpMiddleware  │  ← resize → 1920×1080, convert → WebP, quality 80
└───────────┬───────────┘        also generates 300×300 thumbnail
            │
            ▼
┌───────────────────────┐
│     Cloud Provider     │  ← store processed image + thumbnail
└───────────────────────┘

Non-image content types (e.g. PDF, ZIP) pass through unchanged.


Supported input formats

Format Processed
JPEG / JPG Yes
PNG Yes
GIF Yes
BMP Yes
WebP Yes
TIFF Yes
Other (PDF, ZIP, etc.) No — passed through unchanged

Output formats

ImageOutputFormat Description
Jpeg JPEG with configurable quality
Png PNG (lossless)
WebP WebP — best compression for web
Original Keep the original format (only resize/crop)

Options reference

Property Default Description
MaxWidth 0 (no limit) Maximum output width in pixels
MaxHeight 0 (no limit) Maximum output height in pixels
JpegQuality 80 JPEG quality 1–100 (higher = better quality, larger file)
OutputFormat Original Target output format
ProcessableContentTypes image/jpeg, image/png, image/gif, image/bmp, image/webp, image/tiff Content types that trigger processing
Thumbnail.Width Thumbnail width in pixels
Thumbnail.Height Thumbnail height in pixels
Thumbnail.Suffix "_thumb" Appended to the file name before the extension

Aspect ratio: Images are resized with aspect-ratio preservation (fit inside MaxWidth × MaxHeight without cropping). Thumbnails are cropped to fill the exact Width × Height specified.


Features

Feature Supported
Resize with aspect-ratio preservation Yes
Format conversion (JPEG, PNG, WebP) Yes
JPEG quality control Yes
Thumbnail generation (separate file) Yes
Pass-through for non-image content Yes
Configurable processable MIME types Yes
Works with all Vali-Blob providers Yes

Documentation



Donations

If Vali-Blob is useful to you, consider supporting its development:


License

MIT License

Contributions

Issues and pull requests are welcome on GitHub.

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 was computed.  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
1.0.0 125 3/21/2026