Skip to main content

Orientation

Enum Orientation 

Source
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

Source

pub const fn from_exif(value: u16) -> Option<Self>

The orientation an EXIF Orientation value names, or None for a value outside 1–8.

Source

pub const fn exif(self) -> u8

The EXIF Orientation value, 1–8.

Source

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.

Source

pub const fn clockwise_turns(self) -> u8

Clockwise quarter turns to apply first, 0–3.

Source

pub const fn mirrored(self) -> bool

Whether a left-to-right mirror follows the rotation.

Source

pub const fn transposes(self) -> bool

Whether displaying upright exchanges width and height.

Source

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.

Trait Implementations§

Source§

impl Clone for Orientation

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Orientation

Source§

impl Debug for Orientation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Orientation

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Orientation

Source§

impl Hash for Orientation

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Orientation

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Orientation

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.