Struct EncoderOptions

pub struct EncoderOptions { /* private fields */ }

Options shared by some of the encoders in the zune- family of image crates

Implementations

impl EncoderOptions

const fn jpeg_encode_progressive(&self) -> bool

Whether the jpeg encoder should encode the image in progressive mode

Default is false.

This may be used to create slightly smaller images at the cost of more processing time

const fn jpeg_optimized_huffman_tables(&self) -> bool

Whether the jpeg encoder should optimize huffman tables to create smaller files at the cost of processing time

Default is false.

fn set_jpeg_encode_progressive(self, yes: bool) -> Self

Set whether the jpeg encoder should encode the imagei in progressive mode

Default is false

impl EncoderOptions

fn new(width: usize, height: usize, colorspace: ColorSpace, depth: BitDepth) -> EncoderOptions

Create new encode options

Arguments

  • width: Image width
  • height: Image height
  • colorspace: Image colorspaces
  • depth: Image depth

returns: EncoderOptions

const fn width(&self) -> usize

Get the width for which the image will be encoded in

fn height(&self) -> usize

Get height for which the image will be encoded in

returns: usize

Panics

If height is zero

const fn depth(&self) -> BitDepth

Get the depth for which the image will be encoded in

const fn quality(&self) -> u8

Get the quality for which the image will be encoded with

Lossy

  • Higher quality means some images take longer to write and have large file sizes but they look good (closer to lossless)

  • Lower quality means small images and low quality.

Lossless

  • High quality indicates more time is spent in making the file smaller

  • Low quality indicates less time is spent in making the file bigger

const fn colorspace(&self) -> ColorSpace

Get the colorspace for which the image will be encoded in

const fn effort(&self) -> u8
fn set_width(self, width: usize) -> Self

Set width for the image to be encoded

fn set_height(self, height: usize) -> Self

Set height for the image to be encoded

fn set_depth(self, depth: BitDepth) -> Self

Set depth for the image to be encoded

fn set_quality(self, quality: u8) -> Self

Set quality of the image to be encoded

Quality is clamped from 0..100

Quality means different options depending on the encoder, see get_quality

fn set_colorspace(self, colorspace: ColorSpace) -> Self

Set colorspace for the image to be encoded

fn set_num_threads(self, threads: u8) -> Self

Set the number of threads allowed for multithreaded encoding where supported

Zero means use a single thread

fn set_effort(self, effort: u8) -> Self
const fn num_threads(&self) -> u8

Return number of threads configured for multithreading where possible

This is used for multi-threaded encoders, currently only jpeg-xl

fn set_strip_metadata(self, yes: bool) -> Self

Set whether the encoder should remove metadata from the image

When set to true, supported encoders will strip away metadata from the resulting image. If set to false, where supported, encoders will not remove metadata from images

const fn strip_metadata(&self) -> bool

Whether or not the encoder should remove metadata from the image

The default value is false, and encoders that respect this try to preserve as much data as possible from one image to another

impl EncoderOptions

const fn png_compression_level(&self) -> PngCompression

Get png compression level

fn set_png_compression_level(self, value: PngCompression) -> Self

Set png compression level

Trait Implementations

impl Clone for EncoderOptions

fn clone(&self) -> EncoderOptions

impl Copy for EncoderOptions

impl Debug for EncoderOptions

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

impl Default for EncoderOptions

fn default() -> Self

Auto Trait Implementations

impl Freeze for EncoderOptions

impl RefUnwindSafe for EncoderOptions

impl Send for EncoderOptions

impl Sync for EncoderOptions

impl Unpin for EncoderOptions

impl UnsafeUnpin for EncoderOptions

impl UnwindSafe for EncoderOptions

Blanket Implementations

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

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for EncoderOptions where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for EncoderOptions where T: ?Sized,

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

impl<T> CloneToUninit for EncoderOptions where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for EncoderOptions

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for EncoderOptions where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for EncoderOptions where U: From<T>,

fn into(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<U> for EncoderOptions where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for EncoderOptions where U: TryFrom<T>,

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