Enum JpegTransformOperation
The rotation or flip a lossless JPEG transform applies, in the terms of jpegtran.
public enum JpegTransformOperation
Fields
AutoOrient = 8Whatever the EXIF orientation needs to show the image upright, after which the orientation is set to Normal: the lossless version of AutoOrient(). A file with no orientation, or an upright one, is copied.
FlipHorizontal = 1Mirrored left to right.
FlipVertical = 2Mirrored top to bottom.
None = 0No rotation or flip; with Crop or Grayscale only those apply.
Rotate180 = 4Turned 180°.
Rotate270 = 5Turned 270° clockwise (90° counterclockwise).
Rotate90 = 3Turned 90° clockwise.
Transpose = 6Mirrored along the top-left to bottom-right diagonal: rows become columns.
Transverse = 7Mirrored along the top-right to bottom-left diagonal.
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}");