pub struct Transcoder { /* private fields */ }Available on crate feature
multimedia only.Expand description
Transcodes images of any wide-spread types to JPEG thumbnails. Default settings generate previews similar to SimpleX-Chat previews
Implementations§
Source§impl Transcoder
impl Transcoder
Sourcepub const fn disabled() -> Self
pub const fn disabled() -> Self
Disable transcoding entirely. Useful for pre-made and pictures thumbnails.
Sourcepub const fn jpeg() -> Self
pub const fn jpeg() -> Self
Only convert the image to JPEG(the best quality) without applying any other transformations. Use builder methods to add transformations on top
Sourcepub const fn thumbnail() -> Self
pub const fn thumbnail() -> Self
The default transcoder for thumbnails. Modify defaults with builder methods.
pub const fn is_enabled(&self) -> bool
Sourcepub const fn with_quality(self, quality: u8) -> Self
pub const fn with_quality(self, quality: u8) -> Self
Quality is bound between 1..=100 where 1 is the worst
Sourcepub const fn with_blur(self, sigma: f32) -> Self
pub const fn with_blur(self, sigma: f32) -> Self
sigma < 1.0 - no blur. sigma = 100.0 - max blur
Sourcepub fn transcode_to_jpg(self, bytes: Vec<u8>) -> Result<Vec<u8>, PreviewError>
pub fn transcode_to_jpg(self, bytes: Vec<u8>) -> Result<Vec<u8>, PreviewError>
WARNING: this is a relatively expensive blocking operation, ensure that you call
this method outside the tokio executor with tokio::spawn_blocking or on a dedicated
thread.
Trait Implementations§
Source§impl Clone for Transcoder
impl Clone for Transcoder
Source§fn clone(&self) -> Transcoder
fn clone(&self) -> Transcoder
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for Transcoder
Source§impl Debug for Transcoder
impl Debug for Transcoder
Auto Trait Implementations§
impl Freeze for Transcoder
impl RefUnwindSafe for Transcoder
impl Send for Transcoder
impl Sync for Transcoder
impl Unpin for Transcoder
impl UnsafeUnpin for Transcoder
impl UnwindSafe for Transcoder
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().