Skip to main content

EncoderOptions

Struct EncoderOptions 

Source
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 width(&self) -> usize

Get the width for which the image will be encoded in

Source

pub fn height(&self) -> usize

Get height for which the image will be encoded in

returns: usize

§Panics

If height is zero

Source

pub const fn depth(&self) -> BitDepth

Get the depth for which the image will be encoded in

Source

pub 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 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 colorspace(&self) -> ColorSpace

Get the colorspace for which the image will be encoded in

Source

pub const fn effort(&self) -> u8

Source

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

Set width for the image to be encoded

Source

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

Set height for the image to be encoded

Source

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

Set depth for the image to be encoded

Source

pub fn set_quality(self, quality: u8) -> EncoderOptions

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) -> EncoderOptions

Set colorspace for the image to be encoded

Source

pub fn set_num_threads(self, threads: u8) -> EncoderOptions

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) -> EncoderOptions

Source

pub 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

Source

pub fn set_strip_metadata(self, yes: bool) -> EncoderOptions

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) -> EncoderOptions

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 duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for EncoderOptions

Source§

impl Debug for EncoderOptions

Source§

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

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

impl Default for EncoderOptions

Source§

fn default() -> EncoderOptions

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

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, Ctx> BundleDefault<Ctx> for T
where T: Default,

Source§

fn default_with_context(_: Ctx) -> T

Creates a default value with the given context.
Source§

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

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

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

Source§

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

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more