Skip to main content

JpegEncoder

Struct JpegEncoder 

Source
pub struct JpegEncoder { /* private fields */ }
Expand description

Encodes a baseline JPEG stream.

Implementations§

Source§

impl JpegEncoder

Source

pub const fn new() -> JpegEncoder

An encoder at the default quality.

Source

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.

Source

pub const fn with_subsampling(self, subsampling: Subsampling) -> JpegEncoder

Override the chroma subsampling chosen by quality.

Source

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.

Source

pub const fn progressive(&self) -> bool

Whether this encoder writes a progressive file.

Source

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.

Source

pub const fn subsampling(&self) -> Subsampling

The chosen chroma subsampling.

Trait Implementations§

Source§

impl Debug for JpegEncoder

Source§

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

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

impl Default for JpegEncoder

Source§

fn default() -> JpegEncoder

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

impl Encoder for JpegEncoder

Source§

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>

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>

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>

Embed profile as the image’s ICC colour profile, or write none. Read more
Source§

fn write_header( &mut self, desc: &ImageDescriptor, sink: &mut dyn Sink, ) -> Result<(), PixelsError>

Begin an image, writing any container header. Read more
Source§

fn write_row( &mut self, row: &[u8], sink: &mut dyn Sink, ) -> Result<(), PixelsError>

Write the next row, top to bottom. Read more
Source§

fn finish(&mut self, sink: &mut dyn Sink) -> Result<(), PixelsError>

Finish the image, writing any trailer and flushing the sink. 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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.