pub struct JpegEncoder { /* private fields */ }Expand description
Encodes a baseline JPEG stream.
Implementations§
Source§impl JpegEncoder
impl JpegEncoder
Sourcepub const fn new() -> JpegEncoder
pub const fn new() -> JpegEncoder
An encoder at the default quality.
Sourcepub fn with_quality(quality: u8) -> Result<JpegEncoder, PixelsError>
pub fn with_quality(quality: u8) -> Result<JpegEncoder, PixelsError>
An encoder at an explicit quality, 1..=100.
Chroma subsampling follows quality, as it does in every encoder that exposes one number: 4:4:4 from 90 up, 4:2:0 below. Above 90 the subsampling, not the quantization, becomes the dominant loss, so keeping it on would make the quality number stop meaning anything.
§Errors
Returns PixelsError::InvalidArgument unless quality is 1..=100.
Sourcepub const fn with_subsampling(self, subsampling: Subsampling) -> JpegEncoder
pub const fn with_subsampling(self, subsampling: Subsampling) -> JpegEncoder
Override the chroma subsampling chosen by quality.
Sourcepub const fn with_progressive(self, progressive: bool) -> JpegEncoder
pub const fn with_progressive(self, progressive: bool) -> JpegEncoder
Write a progressive file (sharp’s progressive): a viewer shows a
coarse picture first and sharpens it as the rest arrives, and the
per-scan tables usually make it a few percent smaller. The whole
image’s coefficients are held until Encoder::finish.
Sourcepub const fn progressive(&self) -> bool
pub const fn progressive(&self) -> bool
Whether this encoder writes a progressive file.
Sourcepub fn from_options(options: &EncodeOptions) -> JpegEncoder
pub fn from_options(options: &EncodeOptions) -> JpegEncoder
An encoder configured from generic encode options: quality,
progressive, and chroma_subsampling in place of the one quality
implies.
Sourcepub const fn subsampling(&self) -> Subsampling
pub const fn subsampling(&self) -> Subsampling
The chosen chroma subsampling.
Trait Implementations§
Source§impl Debug for JpegEncoder
impl Debug for JpegEncoder
Source§impl Default for JpegEncoder
impl Default for JpegEncoder
Source§fn default() -> JpegEncoder
fn default() -> JpegEncoder
Source§impl Encoder for JpegEncoder
impl Encoder for JpegEncoder
Source§fn set_exif(&mut self, exif: Option<&[u8]>) -> Result<(), PixelsError>
fn set_exif(&mut self, exif: Option<&[u8]>) -> Result<(), PixelsError>
The block goes in an APP1 segment, which holds at most 65,527
bytes after its Exif\0\0 identifier. A larger block, which no
JPEG could have carried, is not written, as libvips drops it.
Source§fn set_xmp(&mut self, xmp: Option<&[u8]>) -> Result<(), PixelsError>
fn set_xmp(&mut self, xmp: Option<&[u8]>) -> Result<(), PixelsError>
The packet goes in one APP1 segment, which holds at most 65,504
bytes after its identifier; a larger one is not written (extended XMP,
spread over several segments, is not).
Source§fn set_density(&mut self, density: Option<Density>) -> Result<(), PixelsError>
fn set_density(&mut self, density: Option<Density>) -> Result<(), PixelsError>
Written in the JFIF header, rounded to whole pixels per inch or centimetre.
Source§fn set_icc_profile(&mut self, profile: Option<&[u8]>) -> Result<(), PixelsError>
fn set_icc_profile(&mut self, profile: Option<&[u8]>) -> Result<(), PixelsError>
profile as the image’s ICC colour profile, or write none. Read more