Zymergi.Imaging.Magick
11.4.0-alpha
dotnet add package Zymergi.Imaging.Magick --version 11.4.0-alpha
NuGet\Install-Package Zymergi.Imaging.Magick -Version 11.4.0-alpha
<PackageReference Include="Zymergi.Imaging.Magick" Version="11.4.0-alpha" />
<PackageVersion Include="Zymergi.Imaging.Magick" Version="11.4.0-alpha" />
<PackageReference Include="Zymergi.Imaging.Magick" />
paket add Zymergi.Imaging.Magick --version 11.4.0-alpha
#r "nuget: Zymergi.Imaging.Magick, 11.4.0-alpha"
#:package Zymergi.Imaging.Magick@11.4.0-alpha
#addin nuget:?package=Zymergi.Imaging.Magick&version=11.4.0-alpha&prerelease
#tool nuget:?package=Zymergi.Imaging.Magick&version=11.4.0-alpha&prerelease
Zymergi.Imaging.Magick
Magick.NET helpers for cropping images and converting between common web formats (CropTopPixels, CropBottomPixels, EditImage, ToMagickFormat, RearrangeBGRAToRGBA).
Targets .NET 10. No Zymergi dependencies. References Magick.NET-Q16-AnyCPU.
Install
dotnet add package Zymergi.Imaging.Magick
Register in Program.cs
Nothing to register. The helpers are static extension methods. Wrap them in your own service if you want to inject and fake them:
builder.Services.AddSingleton<IThumbnailer, MagickThumbnailer>();
Use it
using ImageMagick;
using Zymergi.Imaging.Magick;
public interface IThumbnailer { byte[] ToWebpBanner(byte[] image, int cropTop); }
public sealed class MagickThumbnailer : IThumbnailer
{
public byte[] ToWebpBanner(byte[] image, int cropTop) =>
image.CropTopPixels(cropTop).EditImage(img =>
{
img.Resize(1200, 0);
return img;
}, format: "image/webp");
}
app.MapPost("/images/banner", async (IFormFile file, IThumbnailer thumbs, CancellationToken ct) =>
{
if (file.Length > 10 * 1024 * 1024) return Results.Problem(statusCode: 413, title: "Image too large");
using var ms = new MemoryStream();
await file.CopyToAsync(ms, ct);
return Results.File(thumbs.ToWebpBanner(ms.ToArray(), 120), "image/webp");
}).DisableAntiforgery().RequireAuthorization();
Best practices
- Image processing is CPU- and memory-heavy and synchronous. Limit upload size, limit concurrency (a
SemaphoreSlimor a rate limiter), and move big jobs to a background queue. - Set Magick.NET resource limits for untrusted input, for example
ResourceLimits.MemoryandResourceLimits.Width/Height, at startup. - Dispose every
MagickImageyou create.EditImagedisposes the image it creates, and the one your callback returns. - Convert to WebP for the web, and store or cache the result instead of converting on every request.
Testing
Use small image fixtures in the test project and assert on the output size and format (new MagickImage(bytes).Width).
Gotchas
CropTopPixelstakes anintandCropBottomPixelstakes auint.ToMagickFormatmapsimage/svg+xml,image/apng,image/webp,image/gif, andimage/jpeg. Every other value, includingimage/avif, silently becomes PNG.- Do not accept SVG from users without sanitizing it; SVG can carry script.
- There are no async APIs.
Version notes
11.4.0-alpha: no API change.
| Product | Versions 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. |
-
net10.0
- Magick.NET-Q16-AnyCPU (>= 14.17.2)
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 |
|---|---|---|
| 11.4.0-alpha | 85 | 11/16/2026 |
| 11.3.0-alpha | 73 | 11/12/2026 |
| 11.2.0-alpha | 62 | 11/2/2026 |
| 11.1.1-alpha | 81 | 10/4/2026 |
| 11.1.0-alpha | 109 | 10/1/2026 |
| 11.0.6-alpha | 117 | 7/10/2026 |
| 11.0.5-alpha | 90 | 7/9/2026 |
| 11.0.4-alpha | 86 | 7/6/2026 |
| 11.0.3-alpha | 85 | 7/6/2026 |
| 11.0.2-alpha | 89 | 6/30/2026 |
| 11.0.1-alpha | 88 | 6/30/2026 |
| 11.0.0-alpha | 87 | 6/30/2026 |