Struct WebPEncoder

pub struct WebPEncoder<W> { /* private fields */ }

WebP Encoder.

Limitations

Right now only lossless encoding is supported.

If you need lossy encoding, you'll have to use libwebp. Example code for encoding a DynamicImage with libwebp via the webp crate can be found here.

Compression ratio

This encoder reaches compression ratios higher than PNG at a fraction of the encoding time. However, it does not reach the full potential of lossless WebP for reducing file size.

If you need an even higher compression ratio at the cost of much slower encoding, please encode the image with libwebp as outlined above.

Implementations

impl<W: Write> WebPEncoder<W>

fn new_lossless(w: W) -> Self

Create a new encoder that writes its output to w.

Uses "VP8L" lossless encoding.

fn encode(self, buf: &[u8], width: u32, height: u32, color_type: ExtendedColorType) -> ImageResult<()>

Encode image data with the indicated color type.

The encoder requires image data be Rgb8 or Rgba8.

Panics

Panics if width * height * color.bytes_per_pixel() != data.len().

Trait Implementations

impl<W: Write> ImageEncoder for WebPEncoder<W>

fn write_image(self, buf: &[u8], width: u32, height: u32, color_type: ExtendedColorType) -> ImageResult<()>
fn set_icc_profile(&mut self, icc_profile: Vec<u8>) -> Result<(), UnsupportedError>
fn set_exif_metadata(&mut self, exif: Vec<u8>) -> Result<(), UnsupportedError>

Auto Trait Implementations

impl<W> Freeze for WebPEncoder<W> where WebPEncoder<W>: Freeze,

impl<W> RefUnwindSafe for WebPEncoder<W> where WebPEncoder<W>: RefUnwindSafe,

impl<W> Send for WebPEncoder<W> where WebPEncoder<W>: Send,

impl<W> Sync for WebPEncoder<W> where WebPEncoder<W>: Sync,

impl<W> Unpin for WebPEncoder<W> where WebPEncoder<W>: Unpin,

impl<W> UnsafeUnpin for WebPEncoder<W> where WebPEncoder<W>: UnsafeUnpin,

impl<W> UnwindSafe for WebPEncoder<W> where WebPEncoder<W>: UnwindSafe,

Blanket Implementations

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for WebPEncoder<W> where ST: ?Sized, DT: ?Sized,

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for WebPEncoder<W> where ST: ?Sized, DT: ?Sized,

impl<T> Any for WebPEncoder<W> where T: 'static + ?Sized,

impl<T> Borrow<T> for WebPEncoder<W> where T: ?Sized,

impl<T> BorrowMut<T> for WebPEncoder<W> where T: ?Sized,

impl<T> From<T> for WebPEncoder<W>

impl<T> IntoEither for WebPEncoder<W>

impl<T> Pointable for WebPEncoder<W>

impl<T> Read<Exclusive, BecauseExclusive> for WebPEncoder<W> where T: ?Sized,

impl<T, U> Into<U> for WebPEncoder<W> where U: From<T>,

impl<T, U> TryFrom<U> for WebPEncoder<W> where U: Into<T>,

impl<T, U> TryInto<U> for WebPEncoder<W> where U: TryFrom<T>,