pub struct Factor { /* private fields */ }Expand description
Factor struct that used for setting quality and resize ratio in the new image.
The Compressor and FolderCompressor need Factor for compressing images.
So, to create a new Compressor or FolderCompressor instance
you need to define a new Factor instance contains the quality ratio of image and file size ratio to compress.
The recommended range of quality is 60 to 80.
Implementations§
Source§impl Factor
impl Factor
Sourcepub fn new(quality: f32, size_ratio: f32) -> Self
pub fn new(quality: f32, size_ratio: f32) -> Self
Create a new Factor instance.
The quality range from 0 to 100 in float,
and size_ratio range from 0 to 1 in float.
§Panics
- If the quality value is 0 or less.
- If the quality value exceeds 100.
- If the size ratio value is 0 or less.
- If the size ratio value exceeds 1.
Sourcepub fn size_ratio(&self) -> f32
pub fn size_ratio(&self) -> f32
Getter for size_ratio of Factor.
Trait Implementations§
Source§impl PartialOrd for Factor
impl PartialOrd for Factor
impl Copy for Factor
impl StructuralPartialEq for Factor
Auto Trait Implementations§
impl Freeze for Factor
impl RefUnwindSafe for Factor
impl Send for Factor
impl Sync for Factor
impl Unpin for Factor
impl UnwindSafe for Factor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().