Struct jpeg_encoder::Encoder [−][src]
pub struct Encoder<W: Write> { /* fields omitted */ }
Implementations
impl<W: Write> Encoder<W>
[src]
impl<W: Write> Encoder<W>
[src]pub fn new(w: W, quality: u8) -> Encoder<W>
[src]
Create a new encoder with the given quality
The quality must be between 1 and 100 where 100 is the highest image quality.
By default, quality settings below 90 use a chroma subsampling (2x2 / 4:2:0) which can
be changed with set_sampling_factor
pub fn set_density(&mut self, density: Density)
[src]
Set pixel density for the image
By default, this value is None which is equal to “1 pixel per pixel”.
pub fn density(&self) -> Density
[src]
Return pixel density
pub fn set_sampling_factor(&mut self, sampling: SamplingFactor)
[src]
Set chroma subsampling factor
pub fn sampling_factor(&self) -> SamplingFactor
[src]
Get chroma subsampling factor
pub fn set_progressive(&mut self, progressive: bool)
[src]
Controls if progressive encoding is used.
By default, progressive encoding uses 4 scans.
Use set_progressive_scans to use a different number of scans
pub fn set_progressive_scans(&mut self, scans: u8)
[src]
Set number of scans per component for progressive encoding
Number of scans must be between 2 and 64. There is at least one scan for the DC coefficients and one for the remaining 63 AC coefficients.
Panics
If number of scans is not within valid range
pub fn progressive_scans(&self) -> Option<u8>
[src]
Return number of progressive scans if progressive encoding is enabled
pub fn set_optimized_huffman_tables(&mut self, optimize_huffman_table: bool)
[src]
Set if optimized huffman table should be created
Optimized tables result in slightly smaller file sizes but decrease encoding performance.
pub fn optimized_huffman_tables(&self) -> bool
[src]
Returns if optimized huffman table should be generated
pub fn add_app_segment(
&mut self,
segment_nr: u8,
data: &[u8]
) -> Result<(), EncodingError>
[src]
&mut self,
segment_nr: u8,
data: &[u8]
) -> Result<(), EncodingError>
Appends a custom app segment to the JFIF file
Segment numbers need to be in the range between 1 and 15
The maximum allowed data length is 2^16 - 2 bytes.
pub fn add_icc_profile(&mut self, data: &[u8]) -> Result<(), EncodingError>
[src]
Add an ICC profile
The maximum allowed data length is 16,707,345 bytes.
pub fn encode(
self,
data: &[u8],
width: u16,
height: u16,
color_type: ColorType
) -> Result<(), EncodingError>
[src]
self,
data: &[u8],
width: u16,
height: u16,
color_type: ColorType
) -> Result<(), EncodingError>
Encode an image
Data format and length must conform to specified width, height and color type.
pub fn encode_image<I: ImageBuffer>(self, image: I) -> Result<(), EncodingError>
[src]
Encode an image
Auto Trait Implementations
impl<W> RefUnwindSafe for Encoder<W> where
W: RefUnwindSafe,
impl<W> RefUnwindSafe for Encoder<W> where
W: RefUnwindSafe,
impl<W> UnwindSafe for Encoder<W> where
W: UnwindSafe,
impl<W> UnwindSafe for Encoder<W> where
W: UnwindSafe,