Skip to content

Latest commit

 

History

History
25 lines (16 loc) · 642 Bytes

cropping.md

File metadata and controls

25 lines (16 loc) · 642 Bytes

Cropping

It is easy to obtain a sub-image of a given image. We can use crop_imm to select a rectangular area and output the area as an image.

fn main() {
    let img = image::open("my_image.jpg").unwrap();

    let img2 = img.crop_imm(128, 128, 384, 640);
    img2.save("crop.jpg").unwrap();
}

Original image:

my_image

crop.jpg:

crop

➡️ Next: Resizing While Preserving Aspect Ratios

📘 Back: Table of contents