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) -> SelfCreate 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,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for WebPEncoder<W>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for WebPEncoder<W>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for WebPEncoder<W>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> IntoEither for WebPEncoder<W>
impl<T> Pointable for WebPEncoder<W>
const ALIGN: usize = _;type Init = T;unsafe fn init(init: <T as Pointable>::Init) -> usizeunsafe fn deref<'a>(ptr: usize) -> &'a Tunsafe fn deref_mut<'a>(ptr: usize) -> &'a mut Tunsafe fn drop(ptr: usize)
impl<T> Read<Exclusive, BecauseExclusive> for WebPEncoder<W>
where
T: ?Sized,
impl<T, U> Into<U> for WebPEncoder<W>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for WebPEncoder<W>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for WebPEncoder<W>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>