pub struct ImageMetadata { /* private fields */ }Expand description
Image metadata
Each image type has this information present The decoder usually sets this up while the encoder can get these details from the user/image struct
Implementations§
Source§impl ImageMetadata
impl ImageMetadata
Sourcepub fn parse_raw_exif(&mut self, data: &[u8])
pub fn parse_raw_exif(&mut self, data: &[u8])
Parse raw Exif and store it as a field in the data
Data should point to the first exif byte
This requires the metadata feature to be activated
otherwise it’s a compile error
Source§impl ImageMetadata
impl ImageMetadata
Sourcepub const fn exif(&self) -> Option<&Vec<Field>>
pub const fn exif(&self) -> Option<&Vec<Field>>
Return the exif metadata of an image or none if it doesn’t exist
Sourcepub fn exif_mut(&mut self) -> Option<&mut Vec<Field>>
pub fn exif_mut(&mut self) -> Option<&mut Vec<Field>>
Return a mutable reference to the exif metadata of an image or none if it doesn’t exist
Sourcepub const fn dimensions(&self) -> (usize, usize)
pub const fn dimensions(&self) -> (usize, usize)
Get image dimensions as a tuple of width and height
§Example
use zune_image::metadata::ImageMetadata;
let meta = ImageMetadata::default();
// default dimensions are usually zero
assert_eq!(meta.dimensions(),(0,0));Sourcepub fn set_dimensions(&mut self, width: usize, height: usize)
pub fn set_dimensions(&mut self, width: usize, height: usize)
Set image dimensions
§Example
use zune_image::metadata::ImageMetadata;
let mut meta = ImageMetadata::default();
// set image dimensions
meta.set_dimensions(23,24);
// get image dimensions
assert_eq!(meta.dimensions(),(23,24));Sourcepub const fn colorspace(&self) -> ColorSpace
pub const fn colorspace(&self) -> ColorSpace
Get an image’s colorspace
The default colorspace is usually ColorSpace::Unknown
which represents an uninitialized image
Sourcepub fn set_colorspace(&mut self, colorspace: ColorSpace)
pub fn set_colorspace(&mut self, colorspace: ColorSpace)
Set the image’s colorspace
Sourcepub const fn color_trc(&self) -> Option<ColorCharacteristics>
pub const fn color_trc(&self) -> Option<ColorCharacteristics>
Get color transfer characteristics
Color transfer characteristics tell us more about how the colorspace values are represented whether they are linear or gamma encoded
Sourcepub fn set_color_trc(&mut self, trc: ColorCharacteristics)
pub fn set_color_trc(&mut self, trc: ColorCharacteristics)
Set color transfer characteristics for this image
Sourcepub const fn depth(&self) -> BitDepth
pub const fn depth(&self) -> BitDepth
Get the image bit depth
Default value is BitDepth::Unknown
which indicates that the bit-depth is currently unknown for a
particular image
Sourcepub fn set_default_gamma(&mut self, gamma: f32)
pub fn set_default_gamma(&mut self, gamma: f32)
Set the default gamma for this image
This is gamma that will be used to convert this image from gamma colorspace to linear colorspace and back.
Do not set this in between operations, and do not set this if you do not know what you are doing.
The library will set this automatically for supported decoders (those which specify gamma during transfer)
§Arguments
- gamma : The new gamma value
Sourcepub const fn image_format(&self) -> Option<ImageFormat>
pub const fn image_format(&self) -> Option<ImageFormat>
Get the image for which this metadata was fetched from
May be None if the caller didn’t set a format
pub const fn alpha(&self) -> AlphaState
pub fn is_premultiplied_alpha(&self) -> bool
pub fn set_alpha(&mut self, alpha_state: AlphaState)
pub fn set_icc_chunk(&mut self, icc_chunk: Vec<u8>)
Sourcepub fn is_linear(&self) -> bool
pub fn is_linear(&self) -> bool
Return whether the image is in linear colorspace or not
if true -> Image in linear colorspace
if false -> Image in gamma colorspace
Sourcepub fn set_linear(&mut self, linear: bool)
pub fn set_linear(&mut self, linear: bool)
Set whether the image is in linear colorspace or not
if true -> Image in linear colorspace
if false -> Image in gamma colorspace
Trait Implementations§
Source§impl Clone for ImageMetadata
impl Clone for ImageMetadata
Source§fn clone(&self) -> ImageMetadata
fn clone(&self) -> ImageMetadata
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ImageMetadata
impl Debug for ImageMetadata
Source§impl Default for ImageMetadata
impl Default for ImageMetadata
Auto Trait Implementations§
impl Freeze for ImageMetadata
impl RefUnwindSafe for ImageMetadata
impl Send for ImageMetadata
impl Sync for ImageMetadata
impl Unpin for ImageMetadata
impl UnsafeUnpin for ImageMetadata
impl UnwindSafe for ImageMetadata
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, Ctx> BundleDefault<Ctx> for Twhere
T: Default,
impl<T, Ctx> BundleDefault<Ctx> for Twhere
T: Default,
Source§fn default_with_context(_: Ctx) -> T
fn default_with_context(_: Ctx) -> T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more