pub enum Orientation {
Upright,
FlipHorizontal,
Rotate180,
FlipVertical,
Transpose,
Rotate90,
Transverse,
Rotate270,
}Expand description
How the stored pixels must be transformed to be shown the right way up.
The eight EXIF orientation values, named for what they do rather than
numbered — Rotate90 is what value 6 means, and nobody remembers that.
Variants§
Upright
Value 1: already upright. Also what a file with no EXIF gets.
FlipHorizontal
Value 2.
Rotate180
Value 3.
FlipVertical
Value 4.
Transpose
Value 5.
Rotate90
Value 6 — the common one: a phone held upright.
Transverse
Value 7.
Rotate270
Value 8.
Implementations§
Source§impl Orientation
impl Orientation
Sourcepub fn from_exif(value: u16) -> Orientation
pub fn from_exif(value: u16) -> Orientation
From the raw EXIF value. Anything outside 1..=8 is
Orientation::Upright — a corrupt tag must not turn a picture
sideways, and “no opinion” is the safe reading of a value nobody
defined.
Sourcepub fn swaps_axes(self) -> bool
pub fn swaps_axes(self) -> bool
Whether applying this swaps width and height.
The half of orientation that is easy to forget, because it is not about pixels: a fit-to-window computed on the stored dimensions of a phone photograph fits the wrong rectangle, and the picture is letterboxed on the wrong axis before anyone notices it is also sideways.
Sourcepub fn applied_size(self, width: u32, height: u32) -> (u32, u32)
pub fn applied_size(self, width: u32, height: u32) -> (u32, u32)
The size a picture presents after this orientation is applied.
Sourcepub fn as_image(self) -> Orientation
pub fn as_image(self) -> Orientation
The equivalent image operation, which is what actually moves the
pixels. Delegated rather than hand-rolled: image::metadata::Orientation is
the same eight cases, and DynamicImage::apply_orientation is
tested by people who do only this.