Skip to main content

SourceMetadata

Struct SourceMetadata 

Source
#[non_exhaustive]
pub struct SourceMetadata {
Show 21 fields pub format: Format, pub size: Option<u64>, pub width: u32, pub height: u32, pub pixel: PixelFormat, pub channels: usize, pub has_alpha: bool, pub bits_per_sample: Option<u8>, pub orientation: Orientation, pub pages: u32, pub animation: Option<Animation>, pub density: Option<Density>, pub progressive: bool, pub palette: bool, pub chroma_subsampling: Option<&'static str>, pub background: Option<Background>, pub compression: Option<&'static str>, pub comments: Vec<Comment>, pub icc: Option<Arc<[u8]>>, pub exif: Option<Arc<[u8]>>, pub xmp: Option<Arc<[u8]>>,
}
Expand description

What a source file says about itself, read from its headers (sharp’s metadata()). Nothing here costs a pixel decode.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§format: Format

The file’s format.

§size: Option<u64>

The file’s size in bytes, when it was opened from a path.

§width: u32

Width as stored, before any orientation is applied.

§height: u32

Height as stored.

§pixel: PixelFormat

The pixel format the decoder produces.

§channels: usize

Channels in that pixel format, alpha included.

§has_alpha: bool

Whether there is an alpha channel.

§bits_per_sample: Option<u8>

Bits per stored sample, which may be fewer than the decoder’s output (a 4-bit PNG, a 10-bit AVIF).

§orientation: Orientation

How the image must be turned to display upright; EXIF’s 1–8 as Orientation::exif gives it.

§pages: u32

Pages in the document, at least 1 (multi-page TIFF).

§animation: Option<Animation>

The animation’s frames, loop count and delays, for more than one frame.

§density: Option<Density>

The stated resolution, if any.

§progressive: bool

Progressive JPEG, or interlaced PNG or GIF.

§palette: bool

Samples index a palette.

§chroma_subsampling: Option<&'static str>

Chroma subsampling as sharp spells it ("4:2:0", "4:4:4", …).

§background: Option<Background>

The background colour the file names (PNG bKGD, GIF).

§compression: Option<&'static str>

The compression scheme where a format has several.

§comments: Vec<Comment>

Text entries (PNG text chunks, JPEG and GIF comments).

§icc: Option<Arc<[u8]>>

The embedded ICC profile.

§exif: Option<Arc<[u8]>>

The EXIF block, TIFF-structured, as the file stores it.

§xmp: Option<Arc<[u8]>>

The XMP packet.

Implementations§

Source§

impl SourceMetadata

Source

pub const fn has_profile(&self) -> bool

Whether the file carries an ICC profile (sharp’s hasProfile).

Source

pub const fn oriented_width(&self) -> u32

Width once turned upright, as sharp’s autoOrient reports it.

Source

pub const fn oriented_height(&self) -> u32

Height once turned upright.

Trait Implementations§

Source§

impl Clone for SourceMetadata

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 Debug for SourceMetadata

Source§

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

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

impl PartialEq for SourceMetadata

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 SourceMetadata

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> 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.