pub struct EncoderOptions { /* private fields */ }
Expand description

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

Implementations§

source§

impl EncoderOptions

source

pub 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

source

pub const fn get_width(&self) -> usize

Get the width for which the image will be encoded in

source

pub fn get_height(&self) -> usize

Get height for which the image will be encoded in

returns: usize

Panics

If height is zero

source

pub const fn get_depth(&self) -> BitDepth

Get the depth for which the image will be encoded in

source

pub const fn get_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 are big but they look good

  • 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

source

pub const fn get_colorspace(&self) -> ColorSpace

Get the colorspace for which the image will be encoded in

source

pub const fn get_effort(&self) -> u8

source

pub fn set_width(self, width: usize) -> Self

Set width for the image to be encoded

source

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

Set height for the image to be encoded

source

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

Set depth for the image to be encoded

source

pub 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

source

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

Set colorspace for the image to be encoded

source

pub 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

source

pub fn set_effort(self, effort: u8) -> Self

source

pub const fn get_num_threads(&self) -> u8

Return number of threads configured for multithreading where possible

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

source

pub 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

source

pub 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

source§

impl EncoderOptions

JPEG options

source

pub 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

source

pub 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.

source

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

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

Default is false

Trait Implementations§

source§

impl Clone for EncoderOptions

source§

fn clone(&self) -> EncoderOptions

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for EncoderOptions

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for EncoderOptions

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Copy for EncoderOptions

Auto Trait Implementations§

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.