pub enum Orientation {
Normal,
FlipHorizontal,
Rotate180,
FlipVertical,
Transpose,
Rotate90,
Transverse,
Rotate270,
}Expand description
One of the eight orientations the EXIF/TIFF Orientation tag (274) can
name.
Each variant describes the transform that makes the stored image upright.
All eight are a clockwise quarter-turn rotation followed, optionally, by a
horizontal mirror, which is the form Orientation::clockwise_turns and
Orientation::mirrored expose and Orientation::from_parts builds
from. HEIF’s rotate-then-mirror properties reduce to the same form.
Variants§
Normal
EXIF 1: already upright.
FlipHorizontal
EXIF 2: mirror left to right.
Rotate180
EXIF 3: rotate 180 degrees.
FlipVertical
EXIF 4: mirror top to bottom.
Transpose
EXIF 5: mirror across the top-left to bottom-right diagonal.
Rotate90
EXIF 6: rotate 90 degrees clockwise.
Transverse
EXIF 7: mirror across the top-right to bottom-left diagonal.
Rotate270
EXIF 8: rotate 270 degrees clockwise, i.e. 90 anticlockwise.
Implementations§
Source§impl Orientation
impl Orientation
Sourcepub const fn from_exif(value: u16) -> Option<Self>
pub const fn from_exif(value: u16) -> Option<Self>
The orientation an EXIF Orientation value names, or None for a value
outside 1–8.
Sourcepub const fn from_parts(turns: u8, mirrored: bool) -> Self
pub const fn from_parts(turns: u8, mirrored: bool) -> Self
Rotate turns quarter turns clockwise (taken modulo 4), then mirror
left to right if mirrored.
Sourcepub const fn clockwise_turns(self) -> u8
pub const fn clockwise_turns(self) -> u8
Clockwise quarter turns to apply first, 0–3.
Sourcepub const fn transposes(self) -> bool
pub const fn transposes(self) -> bool
Whether displaying upright exchanges width and height.
Sourcepub fn from_exif_block(exif: &[u8]) -> Option<Self>
pub fn from_exif_block(exif: &[u8]) -> Option<Self>
Read the Orientation tag from an EXIF block.
exif is the TIFF structure EXIF is made of, optionally behind the
Exif\0\0 identifier a JPEG APP1 segment carries. PNG’s eXIf and
WebP’s EXIF chunk are specified without the identifier, but writers
that copy it across from a JPEG are common, so both are accepted.
A missing tag, an out-of-range value or a malformed block all yield
None rather than an error: broken metadata is not a broken image,
and refusing to decode a photograph over it would be the wrong trade.