To flip an image horizontally or vertically, we can use fliph and flipv.
fn main() {
let img = image::open("my_image.jpg").unwrap();
let img_fliph = img.fliph();
img_fliph.save("fliph.jpg").unwrap();
let img_flipv = img.flipv();
img_flipv.save("flipv.jpg").unwrap();
}
Original image:
fliph.jpg:
flipv.jpg:
We can also use apply_orientation to achieve the same results.
➡️ Next: Rotating
📘 Back: Table of contents