Skip to main content

AvifData

Struct AvifData 

Source
pub struct AvifData {
    pub primary_item: TryVec<u8>,
    pub alpha_item: Option<TryVec<u8>>,
    pub premultiplied_alpha: bool,
    pub grid_config: Option<GridConfig>,
    pub grid_tiles: TryVec<TryVec<u8>>,
    pub animation: Option<AnimationConfig>,
}
๐Ÿ‘ŽDeprecated since 1.5.0: Use AvifParser for zero-copy parsing instead

Fieldsยง

ยงprimary_item: TryVec<u8>
๐Ÿ‘ŽDeprecated since 1.5.0: Use AvifParser for zero-copy parsing instead

AV1 data for the color channels.

The collected data indicated by the pitm box, See ISO 14496-12:2015 ยง 8.11.4

ยงalpha_item: Option<TryVec<u8>>
๐Ÿ‘ŽDeprecated since 1.5.0: Use AvifParser for zero-copy parsing instead

AV1 data for alpha channel.

Associated alpha channel for the primary item, if any

ยงpremultiplied_alpha: bool
๐Ÿ‘ŽDeprecated since 1.5.0: Use AvifParser for zero-copy parsing instead

If true, divide RGB values by the alpha value.

See prem in MIAF ยง 7.3.5.2

ยงgrid_config: Option<GridConfig>
๐Ÿ‘ŽDeprecated since 1.5.0: Use AvifParser for zero-copy parsing instead

Grid configuration for tiled images.

If present, the image is a grid and grid_tiles contains the tile data. Grid layout is determined either from an explicit ImageGrid property box or calculated from ispe (Image Spatial Extents) properties.

ยงExample

#[allow(deprecated)]
use std::fs::File;
#[allow(deprecated)]
let data = zenavif_parse::read_avif(&mut File::open("image.avif")?)?;

if let Some(grid) = data.grid_config {
    println!("Grid: {}ร—{} tiles", grid.rows, grid.columns);
    println!("Output: {}ร—{}", grid.output_width, grid.output_height);
    println!("Tile count: {}", data.grid_tiles.len());
}
ยงgrid_tiles: TryVec<TryVec<u8>>
๐Ÿ‘ŽDeprecated since 1.5.0: Use AvifParser for zero-copy parsing instead

AV1 payloads for grid image tiles.

Empty for non-grid images. For grid images, contains one entry per tile.

Tile ordering: Tiles are guaranteed to be in the correct order for grid assembly, sorted by their dimgIdx (reference index). This is row-major order: tiles in the first row from left to right, then the second row, etc.

ยงanimation: Option<AnimationConfig>
๐Ÿ‘ŽDeprecated since 1.5.0: Use AvifParser for zero-copy parsing instead

Animation configuration (for animated AVIF with avis brand)

When present, primary_item contains the first frame

Implementationsยง

Sourceยง

impl AvifData

Source

pub fn from_reader<R: Read>(reader: &mut R) -> Result<Self>

๐Ÿ‘ŽDeprecated since 1.5.0: Use AvifParser::from_reader() instead
Source

pub fn primary_item_metadata(&self) -> Result<AV1Metadata>

Parses AV1 data to get basic properties of the opaque channel

Source

pub fn alpha_item_metadata(&self) -> Result<Option<AV1Metadata>>

Parses AV1 data to get basic properties about the alpha channel, if any

Trait Implementationsยง

Sourceยง

impl Debug for AvifData

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl Default for AvifData

Sourceยง

fn default() -> AvifData

Returns the โ€œdefault valueโ€ for a type. Read more

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.