#[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
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.