Struct WebPEncoder

struct WebPEncoder<W> { ... }

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: 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().

impl<T> Any for WebPEncoder<W>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for WebPEncoder<W>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for WebPEncoder<W>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for WebPEncoder<W>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Pointable for WebPEncoder<W>

unsafe fn init(init: <T as Pointable>::Init) -> usize
unsafe fn deref<'a>(ptr: usize) -> &'a T
unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
unsafe fn drop(ptr: usize)

impl<T, U> Into for WebPEncoder<W>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for WebPEncoder<W>

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

impl<T, U> TryInto for WebPEncoder<W>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>

impl<W> Freeze for WebPEncoder<W>

impl<W> RefUnwindSafe for WebPEncoder<W>

impl<W> Send for WebPEncoder<W>

impl<W> Sync for WebPEncoder<W>

impl<W> Unpin for WebPEncoder<W>

impl<W> UnsafeUnpin for WebPEncoder<W>

impl<W> UnwindSafe for WebPEncoder<W>

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

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