Table of Contents

Enum JpegTransformEdges

Namespace
Egami.Formats.Jpeg
Assembly
Egami.dll

What a lossless transform does with the blocks at the right or bottom edge when the image is not a whole number of MCUs (8 or 16 pixels) across or down, so those blocks cannot move to the other side intact.

public enum JpegTransformEdges

Fields

Keep = 2

Leaves partial MCUs where they are, unmirrored, as jpegtran does by default: every pixel is kept, but a strip up to 15 pixels wide at the edge is not turned with the rest.

Strict = 1

Throws InvalidOperationException when a partial MCU would have to move, as jpegtran -perfect does, so the result is always exact and full size.

Trim = 0

Drops the partial MCU from an edge that is mirrored, so the image loses up to 15 pixels there (up to 7 for gray), as jpegtran -trim does. Edges that stay in place keep every pixel.

Examples

// Turns the photo upright by its EXIF orientation without re-encoding: no quality is lost, and the tag is reset.
JpegTransform.Apply("sideways.jpg", "upright.jpg", new JpegTransformOptions { Operation = JpegTransformOperation.AutoOrient });

// Rotates, crops and drops the color in one pass; a file can be transformed in place.
JpegTransformResult result = JpegTransform.Apply("upright.jpg", "upright.jpg", new JpegTransformOptions
{
    Operation = JpegTransformOperation.Rotate90,
    Crop = new Rect(0, 0, 200, 120),
    Grayscale = true,
});
Console.WriteLine($"{result.Width} × {result.Height}");