pub enum Orientation {
NoTransforms,
Rotate90,
Rotate180,
Rotate270,
FlipHorizontal,
FlipVertical,
Rotate90FlipH,
Rotate270FlipH,
}
Expand description
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§
Source§impl Orientation
impl Orientation
Sourcepub fn from_exif(exif_orientation: u8) -> Option<Self>
pub fn from_exif(exif_orientation: u8) -> Option<Self>
Converts from Exif orientation
Sourcepub fn to_exif(self) -> u8
pub fn to_exif(self) -> u8
Converts into Exif orientation
Sourcepub fn from_exif_chunk(chunk: &[u8]) -> Option<Self>
pub 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.
Sourcepub fn remove_from_exif_chunk(chunk: &mut [u8]) -> Option<Self>
pub 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, None
is returned and the Exif chunk is not modified.
Trait Implementations§
Source§impl Clone for Orientation
impl Clone for Orientation
Source§fn clone(&self) -> Orientation
fn clone(&self) -> Orientation
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more