Skip to content

Latest commit

 

History

History
41 lines (25 loc) · 1.15 KB

rotating.md

File metadata and controls

41 lines (25 loc) · 1.15 KB

Rotating

There are convenient methods for rotating images. We can use rotate90, rotate180 and rotate270 to rotate an image clockwise by the specified degree.

fn main() {
    let img = image::open("my_image.jpg").unwrap();
    
    let img_90 = img.rotate90();
    img_90.save("rotate90.jpg").unwrap();
    
    let img_180 = img.rotate180();
    img_180.save("rotate180.jpg").unwrap();
    
    let img_270 = img.rotate270();
    img_270.save("rotate270.jpg").unwrap();
}

Original image:

my_image

rotate90.jpg:

rotate90

rotate180.jpg:

rotate180

rotate270.jpg:

rotate270

We can also use apply_orientation to achieve the same results.

➡️ Next: Cropping

📘 Back: Table of contents