[−][src]Struct mozjpeg::Compress
Create a new JPEG file from pixels
Wrapper for jpeg_compress_struct
Implementations
impl Compress
[src]
pub fn new(color_space: ColorSpace) -> Compress
[src]
Compress image using input in this colorspace
By default errors cause panic and unwind through the C code, which strictly speaking is not guaranteed to work in Rust (but seems to work fine, at least in x86/64).
pub fn new_err(err: ErrorMgr, color_space: ColorSpace) -> Compress
[src]
Use a specific error handler instead of the default panicking one
color_space
refers to input color space
pub fn start_compress(&mut self)
[src]
Settings can't be changed after this call
pub fn write_marker(&mut self, marker: Marker, data: &[u8])
[src]
Add a marker to compressed file
Data is max 64KB
pub fn components_mut(&mut self) -> &mut [CompInfo]
[src]
Expose components for modification, e.g. to set chroma subsampling
pub fn components(&self) -> &[CompInfo]
[src]
Read-only view of component information
pub fn write_scanlines(&mut self, image_src: &[u8]) -> bool
[src]
Returns true if all lines in image_src (not necessarily all lines of the image) were written
pub fn write_raw_data(&mut self, image_src: &[&[u8]]) -> bool
[src]
Advanced. Only possible after set_raw_data_in()
.
Write YCbCr blocks pixels instead of usual color space
See raw_data_in
in libjpeg docs
pub fn set_color_space(&mut self, color_space: ColorSpace)
[src]
Set color space of JPEG being written, different from input color space
See jpeg_set_colorspace
in libjpeg docs
pub fn set_size(&mut self, width: usize, height: usize)
[src]
Image size of the input
pub fn set_gamma(&mut self, gamma: f64)
[src]
it doesn't do anything
libjpeg's input_gamma
= image gamma of input image
pub fn set_optimize_scans(&mut self, opt: bool)
[src]
If true, it will use MozJPEG's scan optimization. Makes progressive image files smaller.
pub fn set_optimize_coding(&mut self, opt: bool)
[src]
Set to false
to make files larger for no reason
pub fn set_use_scans_in_trellis(&mut self, opt: bool)
[src]
Specifies whether multiple scans should be considered during trellis quantization.
pub fn set_progressive_mode(&mut self)
[src]
You can only turn it on
pub fn set_scan_optimization_mode(&mut self, mode: ScanMode)
[src]
One scan for all components looks best. Other options may flash grayscale or green images.
pub fn set_fastest_defaults(&mut self)
[src]
Reset to libjpeg v6 settings
It gives files identical with libjpeg-turbo
pub fn set_raw_data_in(&mut self, opt: bool)
[src]
Advanced. See raw_data_in
in libjpeg docs.
pub fn set_quality(&mut self, quality: f32)
[src]
Set image quality. Values 60-80 are recommended.
pub fn set_luma_qtable(&mut self, qtable: &QTable)
[src]
Instead of quality setting, use a specific quantization table.
pub fn set_chroma_qtable(&mut self, qtable: &QTable)
[src]
Instead of quality setting, use a specific quantization table for color.
pub fn set_mem_dest(&mut self)
[src]
Write to in-memory buffer
pub fn finish_compress(&mut self)
[src]
Finalize compression. In case of progressive files, this may actually start processing.
pub fn data_as_mut_slice(&mut self) -> Result<&[u8], ()>
[src]
If set_mem_dest()
was enabled, this is the result
pub fn data_to_vec(&mut self) -> Result<Vec<u8>, ()>
[src]
If set_mem_dest()
was enabled, this is the result. Can be called once only.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Compress
[src]
impl !Send for Compress
[src]
impl !Sync for Compress
[src]
impl Unpin for Compress
[src]
impl UnwindSafe for Compress
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,