Struct turbojpeg::Transform

source ·
#[non_exhaustive]
pub struct Transform { pub op: TransformOp, pub crop: Option<TransformCrop>, pub perfect: bool, pub trim: bool, pub gray: bool, pub progressive: bool, pub optimize: bool, pub copy_none: bool, }
Expand description

Lossless transform of a JPEG image.

When constructing an instance, you may start from the default transform (Transform::default()) or from an operation (Transform::op()) and modify only the fields that you need.

§Examples

Rotate image clockwise by 90 degrees:

let transform = Transform::op(TransformOp::Rot90);

Rotate image counterclockwise by 90 degrees and fail if the transform is not perfect:

let mut transform = Transform::op(TransformOp::Rot270);
transform.perfect = true;

Flip image vertically and trim the image on the right edge if the transform is imperfect:

let mut transform = Transform::op(TransformOp::Vflip);
transform.trim = true;

Crop image to size (200, 100) starting at pixel (16, 32), without applying any transform:

let mut transform = Transform::default();
transform.crop = Some(TransformCrop { x: 16, y: 32, width: Some(200), height: Some(100) });

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§op: TransformOp

Transform operation that is applied.

§crop: Option<TransformCrop>

Crop the input image before applying the transform.

§perfect: bool

Return an error if the transform is not perfect.

Lossless transforms operate on MCU blocks, whose size depends on the level of chrominance subsampling used (see Subsamp::mcu_width() and Subsamp::mcu_height()). If the image width or height is not evenly divisible by the MCU block size, then there will be partial MCU blocks on the right and bottom edges. It is not possible to move these partial MCU blocks to the top or left of the image, so any transform that would require that is “imperfect”.

If this option is not specified and trim is not enabled, then any partial MCU blocks that cannot be transformed will be left in place, which will create odd-looking strips on the right or bottom edge of the image.

§trim: bool

Discard any partial MCU blocks that cannot be transformed.

§gray: bool

Discard the color data in the input image and produce a grayscale output image.

§progressive: bool

Enable progressive entropy coding in the output image generated by this particular transform.

Progressive entropy coding will generally improve compression relative to baseline entropy coding (the default), but it will reduce compression and decompression performance considerably.

§optimize: bool

Enable optimized baseline entropy coding in the JPEG image generated by this particular transform.

Optimized baseline entropy coding will improve compression slightly (generally 5% or less.)

§copy_none: bool

Do not copy any extra markers (including EXIF and ICC profile data) from the input image to the output image.

Implementations§

source§

impl Transform

source

pub fn op(op: TransformOp) -> Transform

Creates a Transform with the given op and all other parameters set to default.

§Example
let mut transform = Transform::op(TransformOp::Rot90);
transform.progressive = true;

Trait Implementations§

source§

impl Clone for Transform

source§

fn clone(&self) -> Transform

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Transform

source§

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

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

impl Default for Transform

source§

fn default() -> Transform

Returns the “default value” for a type. 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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.