Enum Orientation
pub enum Orientation
Describes the transformations to be applied to the image. Compatible with Exif orientation.
Orientation is specified in the file's metadata, and is often written by cameras.
You can apply it to an image via DynamicImage::apply_orientation.
Variants
-
NoTransforms Do not perform any transformations.
-
Rotate90 Rotate by 90 degrees clockwise.
-
Rotate180 Rotate by 180 degrees. Can be performed in-place.
-
Rotate270 Rotate by 270 degrees clockwise. Equivalent to rotating by 90 degrees counter-clockwise.
-
FlipHorizontal Flip horizontally. Can be performed in-place.
-
FlipVertical Flip vertically. Can be performed in-place.
-
Rotate90FlipH Rotate by 90 degrees clockwise and flip horizontally.
-
Rotate270FlipH Rotate by 270 degrees clockwise and flip horizontally.
Implementations
impl Orientation
fn from_exif(exif_orientation: u8) -> Option<Self>Converts from Exif orientation
fn to_exif(self) -> u8Converts into Exif orientation
fn from_exif_chunk(chunk: &[u8]) -> Option<Self>Extracts the image orientation from a raw Exif chunk.
You can obtain the Exif chunk using ImageDecoder::exif_metadata.
It is more convenient to use ImageDecoder::orientation than to invoke this function. Only use this function if you extract and process the Exif chunk separately.
fn remove_from_exif_chunk(chunk: &mut [u8]) -> Option<Self>Extracts the image orientation from a raw Exif chunk and sets the orientation in the Exif chunk to
Orientation::NoTransforms. This is useful if you want to apply the orientation yourself, and then encode the image with the rest of the Exif chunk intact.If the orientation data is not cleared from the Exif chunk after you apply the orientation data yourself, the image will end up being rotated once again by any software that correctly handles Exif, leading to an incorrect result.
If the Exif value is present but invalid,
Noneis returned and the Exif chunk is not modified.
Trait Implementations
impl Clone for Orientation
fn clone(&self) -> Orientation
impl Copy for Orientation
impl Debug for Orientation
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for Orientation
impl Hash for Orientation
fn hash<__H: Hasher>(&self, state: &mut __H)
impl PartialEq for Orientation
fn eq(&self, other: &Orientation) -> bool
impl StructuralPartialEq for Orientation
Auto Trait Implementations
impl Freeze for Orientation
impl RefUnwindSafe for Orientation
impl Send for Orientation
impl Sync for Orientation
impl Unpin for Orientation
impl UnsafeUnpin for Orientation
impl UnwindSafe for Orientation
Blanket Implementations
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for Orientation
where
ST: ?Sized,
DT: ?Sized,
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for Orientation
where
ST: ?Sized,
DT: ?Sized,
impl<T> Any for Orientation
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Orientation
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Orientation
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Orientation
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Orientation
fn from(t: T) -> TReturns the argument unchanged.
impl<T> IntoEither for Orientation
impl<T> Pointable for Orientation
const ALIGN: usize = _;type Init = T;unsafe fn init(init: <T as Pointable>::Init) -> usizeunsafe fn deref<'a>(ptr: usize) -> &'a Tunsafe fn deref_mut<'a>(ptr: usize) -> &'a mut Tunsafe fn drop(ptr: usize)
impl<T> Read<Exclusive, BecauseExclusive> for Orientation
where
T: ?Sized,
impl<T> ToOwned for Orientation
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for Orientation
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Orientation
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Orientation
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>