Skip to content
Open source · MIT · net10.0 / net11.0

Images for Blazor,
processed in C#.

Load, crop, resize, adjust, annotate, redact and export images entirely on the user's device, from strongly typed C#. No server round trips, no base64, no JavaScript image library - and a complete editor component when you want a UI instead of a pipeline.

dotnet add package Bit.Bmage.Blazor
ProfilePhoto.razor
using var photo = await Loader.LoadAsync(e.File);

using var avatar = await ImagePipeline.Create()
    .AutoOrient()
    .SmartCrop(AspectRatio.Square)   // finds the subject
    .Resize(240, 240)
    .Sepia(0.7f)
    .Vignette(0.5f)
    .ExecuteAsync(photo);

The scene is drawn by the library's own canvas and processed in your browser.

Engine in C#resampler, rasteriser, colour pipeline and six codecs, WebP and AVIF among them
On the devicethe original never leaves the browser
AVIF exportsfrom the browser's codecs, probed rather than assumed
Private by defaultmetadata is removed unless you keep it

Capabilities

An image platform, not an interop wrapper

Nine decisions run through the whole library. Every tile links to the page that shows the decision paying off - with a sample that runs on your own image.

Non-destructive by construction

An edit is an immutable ImagePipeline - a list of operations, not a mutated buffer. Undo costs a few hundred bytes, previews are cheap, and the optimiser fuses per-pixel steps into one pass.

Pipelines →

A complete editor component

BmageEditor crops, straightens, adjusts, filters, selects, paints, annotates, redacts, layers and exports, and saves projects that reopen editable - themed through CSS custom properties, localised, keyboard accessible and right-to-left aware.

The editor →

Large images stay usable

Editing runs on a proxy sized for the display and replays at full resolution on export, so a 24 megapixel photo does not stall the interface.

Performance →

Privacy is the default

Metadata is removed unless you ask for it, so GPS coordinates never leak into an exported avatar by accident - and the page proves it by reading the exported bytes back.

Metadata and privacy →

Nothing assumed about the browser

Format support is probed by encoding a pixel. When a browser would hand back a PNG for the AVIF you asked for, you get an exception, not a mislabelled file.

Capabilities →

Headless first

Every capability works without the editor, so the same pipeline runs in an upload handler, a thumbnail service or a console tool with the managed codecs.

Headless API →

Selective edits and layers

Any edit applies through a mask - a gradient, a spotlight, a tone or colour range, a magic wand - and image, fill, adjustment and paint layers composite with the W3C blend modes, in groups and clipped to the layer below.

Layers and masks →

Edits are data

A whole edit - pipeline, layers, masks and annotations - writes to JSON and reads back as the same edit, so the browser can send the edit instead of the pixels, and a project file reopens with every step still editable.

Retouching and projects →

Every core, predictable memory

Operations spread their rows over as many threads as you allow with identical pixels, browser codecs run in Web Workers, and a pipeline estimates its peak memory before it runs.

Threads and memory →

In practice

See it in code

01

One package, one registration

The browser codecs, loading and export and the editor component are in Bit.Bmage.Blazor, which brings the engine, Bit.Bmage, along. One call registers the loader, the exporter and the capability probe.

Getting started →
// Program.cs
using Bit.Bmage;

builder.Services.AddBitBmageServices();
02

Decode, process, encode

The browser decodes the upload and applies the phone's rotation, a pipeline does the pixel work, and the exporter writes WebP through the browser's encoder - or, in WebAssembly where the browser cannot write WebP, such as Safari's, the JPEG next in the list. On a server, Bmage's own WebP encoder writes it.

Pipelines →
using var image = await Loader.LoadAsync(e.File);

using var processed = await ImagePipeline.Create()
    .MaxSize(800, 800)
    .Sharpen(0.3f)
    .ExecuteAsync(image);

var encoded = await Exporter.EncodeWithFallbackAsync(
    processed,
    [ImageFormat.WebP, ImageFormat.Jpeg],
    new ImageExportOptions { Quality = 0.85 });
03

Or drop in the whole editor

When what you want is an editing UI rather than a pipeline, it is one component. It fills its container, so give the container a height.

The editor →
<div style="height: 70vh">
    <BmageEditor @ref="_editor" OnExported="OnExported" />
</div>

Comparison

Why not wrap a JavaScript image library?

The usual way to crop an avatar in Blazor is to send the full-resolution file to a server, or to put several JavaScript libraries behind hand-written interop. Bmage keeps the engine in C# and uses the browser only for what only it can do.

ConcernJavaScript library over interopBmage
Where the pixels are processedIn script, behind interop calls you write and maintainIn C# - the browser decodes, writes WebP and AVIF, and draws
The APIOption bags and untyped resultsAn immutable ImagePipeline and typed export options
Format supportAssumed, or read from the user agentProbed by encoding a pixel; a substituted PNG is refused
MetadataWhatever the library passes throughRemoved by default, with three explicit policies
On a serverA second library, a second set of resultsThe same pipeline, headless, with the managed codecs

Where to start

Choose your path

New to Bmage?

Install, register, and process your first image - with the snippet runnable on the page.

Getting started →

Building a feature?

Avatars, screenshots, upload optimisation, product and social images, retouching, batches - each a working page with its source.

Open the workflows →

Processing on a server?

The engine has no UI dependency: register the headless services and run the same pipelines in an endpoint.

Headless API →

Building with an AI agent?

This site is an MCP server: point your agent at /mcp and it reads the shipped library - and runs its pipelines - instead of guessing.

Try the MCP server →

Questions

Frequently asked

Does the image leave the user's device?

Not on WebAssembly, which is where Bmage is meant to run: the file is decoded, processed and encoded in the browser, and only the result goes wherever your code sends it. Interactive Server works too, but there the pixels cross the circuit to be processed. In a Blazor Hybrid (MAUI) app they stay on the device as well: .NET runs inside the app.

Which frameworks and render modes are supported?

.NET 10 and 11. Everything works on Blazor WebAssembly and on Interactive Auto once interactive, and on Interactive Server and Blazor Hybrid (MAUI, WPF, Windows Forms), where .NET reaches the browser over interop; prerendering, ASP.NET Core and console hosts get the headless API with the managed PNG, JPEG, BMP and GIF codecs.

Is C# fast enough for pixel work in a browser?

Yes. The pixel loops are written for Blazor's default IL interpreter, and the browser does the work it is fastest at, so the editor opens a 12 megapixel photo in about 50 ms even there. Publishing the browser project with RunAOTCompilation makes what stays in .NET 4 to 12× faster still.

Can it write WebP and AVIF?

WebP everywhere, a server included: Bmage has its own WebP encoder, lossy and lossless, for wherever the browser has none. AVIF through the browser's own codecs, wherever the browser can - which Bmage probes rather than assumes. Ask for a preference order with EncodeWithFallbackAsync, or get an ImageCapabilityException instead of a silently substituted PNG.

Can an edit be saved and reopened later?

Yes, two ways. BmageJson writes the edit itself - pipeline, layers, masks and annotations - as JSON that references its images, so a server can replay it on the original at full resolution. BmageProject writes one file with the original and every image inside, and the editor reopens it with each step still editable.

What about animated GIFs and SVG?

A GIF decodes to its first frame. SVG is refused with an explanatory error rather than rasterised, because rendering untrusted SVG can run scripts and fetch remote resources.

Start processing

One package and one service registration - and every image your users pick is yours to shape on their device.

dotnet add package Bit.Bmage.Blazor
An unhandled error has occurred. Reload 🗙