Skip to content

Operations Reference

Complete catalogue of transformations and filters available on ImagePipeline. All operations modify the pipeline in place and return this for chaining.


Resize to exact dimensions. Does not preserve aspect ratio — if the ratio differs from the source, the image is stretched.

pipe.Resize(800, 600, ResizeFilter.Lanczos3);

ResizeFilter values, in order of quality/cost:

FilterWhen to use
NearestPixel art, speed-critical paths; fastest
TriangleQuick downscale, acceptable quality
CatmullRomGood general-purpose, moderate cost
MitchellSmooth downscale
GaussianSoft result, useful for thumbnails
Lanczos3Highest-quality (default)

Fit the image inside the bounding box while preserving aspect ratio. At most one dimension hits the bound; the other is smaller.

pipe.Thumbnail(400, 400); // fits a 800×600 into 400×300
pipe.Thumbnail(400, 400, ResizeFilter.CatmullRom); // faster than Lanczos3

If the source is already smaller than the bounds, Thumbnail is a no-op.

Cut a rectangular region. Coordinates are in pixels from the top-left corner.

pipe.Crop(x: 100, y: 100, width: 400, height: 300);

Cropping past the image bounds throws ImagingException { Reason = InvalidArgument }.

Rotate by 90, 180, or 270 degrees (positive = clockwise). Arbitrary angles are not supported — the native layer only does lossless 90° rotations.

pipe.Rotate(90); // landscape → portrait
pipe.Rotate(270); // equivalent to Rotate(-90)

Passing any other value throws.

Mirror the image along the corresponding axis.

pipe.FlipHorizontal(); // left-right mirror
pipe.FlipVertical(); // top-bottom mirror

Convert to luminance-preserving grayscale. The pixel format remains RGB / RGBA — pixels just have equal R=G=B channels.

pipe.Grayscale();

Gaussian blur. sigma is the standard deviation in pixels; sigma=1.0 is a light blur, 5.0 is heavy.

pipe.Blur(sigma: 2.0f);

Unsharp-mask sharpening. sigma controls the radius of the underlying blur; threshold is the minimum pixel difference (0-255) that triggers sharpening.

pipe.Sharpen(sigma: 1.0f, threshold: 1); // default
pipe.Sharpen(sigma: 1.5f, threshold: 3); // stronger, ignores micro-noise

Low threshold sharpens everything (including noise); high threshold preserves smooth areas.

Add or subtract a constant to every RGB channel. Range -128 to +128.

pipe.Brightness(20); // brighten
pipe.Brightness(-30); // darken

Values outside the range are clamped native-side.

Multiplicative contrast. 1.0 is identity; >1.0 increases contrast; <1.0 flattens.

pipe.Contrast(1.2f); // 20% more contrast
pipe.Contrast(0.8f); // flatter

Serialise the current pipeline state to the stream. Quality ignored for PNG (lossless); applies to JPEG and WebP (0-100).

pipe.EncodeTo(output, ImageFormat.Png);
pipe.EncodeTo(output, ImageFormat.Jpeg, quality: 85);
pipe.EncodeTo(output, ImageFormat.Webp, quality: 80);

Supported output formats: PNG, JPEG, WebP, BMP.

After EncodeTo, the pipeline’s native buffer is released. Call Load again for a fresh pipeline.


ImageInfo.FromBytes(bytes) / FromStream(stream, maxBytes)

Section titled “ImageInfo.FromBytes(bytes) / FromStream(stream, maxBytes)”

Parse the format header to read dimensions without a full decode. Returns:

public sealed record ImageInfo(
ImageFormat Format,
uint Width,
uint Height);

Header-only parsing means this is cheap — use it to validate uploads before committing to a full ImagePipeline.Load.


QrCode.GeneratePng(text, output, moduleSize, margin)

Section titled “QrCode.GeneratePng(text, output, moduleSize, margin)”

Emit a PNG-encoded QR code directly to a stream.

ParameterDefaultMeaning
textPayload — URL, text, any UTF-8 string
outputTarget stream
moduleSize10Pixels per QR module
margin2Quiet-zone size in modules

Error correction level is fixed at Medium (automatic from qrcode crate defaults). For other levels or output formats, use a dedicated QR library.


Typical transform chains:

// Thumbnail for a gallery
pipe.Thumbnail(400, 400, ResizeFilter.CatmullRom)
.EncodeTo(out, ImageFormat.Webp, quality: 80);
// Sharpened grayscale scan
pipe.Resize(2048, 2048)
.Grayscale()
.Sharpen(sigma: 1.5f, threshold: 2)
.EncodeTo(out, ImageFormat.Png);
// Rotate + crop + re-encode
pipe.Rotate(90)
.Crop(x: 100, y: 200, width: 600, height: 400)
.EncodeTo(out, ImageFormat.Jpeg, quality: 90);

Operations are applied in order. Ordering matters: Crop → Resize keeps the crop; Resize → Crop crops from the resized image.


ImageConverter (in Pragmatic.Imaging) provides one-liner helpers that wrap the pipeline:

  • ImageConverter.ThumbnailAsync(bytes, maxWidth, maxHeight, format, quality, options, ct)
  • ImageConverter.ResizeAsync(bytes, width, height, format, quality, options, ct)
  • ImageConverter.ConvertAsync(bytes, format, quality, options, ct)
  • ImageConverter.StripMetadataAsync(bytes, format, quality, options, ct)

These are convenience wrappers — they open a pipeline, do the operation, encode, and return byte[].

ImageBatch wraps these for concurrent processing of multiple inputs.


  • Arbitrary-angle rotation
  • Text overlay / drawing
  • Colour-space conversion (sRGB assumed throughout)
  • Animation frames (GIF / APNG / animated WebP — first frame only)
  • EXIF-preserving operations (EXIF is stripped on re-encode)
  • Floating-point pixel formats
  • HDR imagery

For any of the above, use ImageSharp or a dedicated tool.