image_webp

Struct WebPDecoder

source
pub struct WebPDecoder<R> { /* private fields */ }
Expand description

WebP image format decoder.

Implementations§

source§

impl<R: BufRead + Seek> WebPDecoder<R>

source

pub fn new(r: R) -> Result<WebPDecoder<R>, DecodingError>

Create a new WebPDecoder from the reader r. The decoder performs many small reads, so the reader should be buffered.

source

pub fn set_memory_limit(&mut self, limit: usize)

Sets the maximum amount of memory that the decoder is allowed to allocate at once.

TODO: Some allocations currently ignore this limit.

source

pub fn set_background_color( &mut self, color: [u8; 4], ) -> Result<(), DecodingError>

Sets the background color if the image is an extended and animated webp.

source

pub fn dimensions(&self) -> (u32, u32)

Returns the (width, height) of the image in pixels.

source

pub fn has_alpha(&self) -> bool

Returns whether the image has an alpha channel. If so, the pixel format is Rgba8 and otherwise Rgb8.

source

pub fn is_animated(&self) -> bool

Returns true if the image is animated.

source

pub fn is_lossy(&mut self) -> bool

Returns whether the image is lossy. For animated images, this is true if any frame is lossy.

source

pub fn num_frames(&self) -> u32

Returns the number of frames of a single loop of the animation, or zero if the image is not animated.

source

pub fn loop_count(&self) -> LoopCount

Returns the number of times the animation should loop.

source

pub fn loop_duration(&self) -> u64

Returns the total duration of one loop through the animation in milliseconds, or zero if the image is not animated.

This is the sum of the durations of all individual frames of the image.

source

pub fn icc_profile(&mut self) -> Result<Option<Vec<u8>>, DecodingError>

Returns the raw bytes of the ICC profile, or None if there is no ICC profile.

source

pub fn exif_metadata(&mut self) -> Result<Option<Vec<u8>>, DecodingError>

Returns the raw bytes of the EXIF metadata, or None if there is no EXIF metadata.

source

pub fn xmp_metadata(&mut self) -> Result<Option<Vec<u8>>, DecodingError>

Returns the raw bytes of the XMP metadata, or None if there is no XMP metadata.

source

pub fn output_buffer_size(&self) -> Option<usize>

Returns the number of bytes required to store the image or a single frame, or None if that would take more than usize::MAX bytes.

source

pub fn read_image(&mut self, buf: &mut [u8]) -> Result<(), DecodingError>

Returns the raw bytes of the image. For animated images, this is the first frame.

source

pub fn read_frame(&mut self, buf: &mut [u8]) -> Result<u32, DecodingError>

Reads the next frame of the animation.

The frame contents are written into buf and the method returns the duration of the frame in milliseconds. If there are no more frames, the method returns DecodingError::NoMoreFrames and buf is left unchanged.

§Panics

Panics if the image is not animated.

source

pub fn reset_animation(&mut self)

Resets the animation to the first frame.

§Panics

Panics if the image is not animated.

Auto Trait Implementations§

§

impl<R> Freeze for WebPDecoder<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for WebPDecoder<R>
where R: RefUnwindSafe,

§

impl<R> Send for WebPDecoder<R>
where R: Send,

§

impl<R> Sync for WebPDecoder<R>
where R: Sync,

§

impl<R> Unpin for WebPDecoder<R>
where R: Unpin,

§

impl<R> UnwindSafe for WebPDecoder<R>
where R: UnwindSafe,

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.