putz u in dhe washing machin and spins ur bsky pofile pictuer !!! :D
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refac: mv rotating to separate function

did:plc:73gqgbnvpx5syidcponjri… dd71a6ac 8e6884cc

verified
+17 -14
+17 -14
src/main.rs
··· 1 - use image::open; 1 + use image::{DynamicImage, open}; 2 2 use imageproc::geometric_transformations::{Interpolation, rotate}; 3 3 use std::{env, process}; 4 4 ··· 7 7 process::exit(1); 8 8 } 9 9 10 + fn rotate_image(image: DynamicImage, radians: f32) -> image::RgbaImage { 11 + let width = image.width(); 12 + let height = image.height(); 13 + 14 + let rotated = rotate( 15 + &image.to_rgba8(), 16 + (width as f32 / 2.0, height as f32 / 2.0), 17 + radians.to_radians(), 18 + Interpolation::Bilinear, 19 + image::Rgba([0, 0, 0, 0]), 20 + ); 21 + 22 + rotated 23 + } 24 + 10 25 fn main() { 11 26 let mut args = env::args(); 12 27 let executable = args.next().unwrap_or_else(|| "washing-machine".to_string()); ··· 18 33 return; 19 34 } 20 35 }; 21 - 22 36 let output = match args.next() { 23 37 Some(p) => p, 24 38 None => { ··· 33 47 process::exit(1); 34 48 }); 35 49 36 - let width = image.width(); 37 - let height = image.height(); 38 - 39 - let rotated = rotate( 40 - &image.to_rgba8(), 41 - (width as f32 / 2.0, height as f32 / 2.0), 42 - (45.0 as f32).to_radians(), 43 - Interpolation::Bilinear, 44 - image::Rgba([0, 0, 0, 0]), 45 - ); 46 - 50 + let rotated = rotate_image(image, 180.0); 47 51 rotated.save(&output).unwrap_or_else(|e| { 48 52 eprintln!("failed to save '{}': {}", output.to_string(), e); 49 - process::exit(1); 50 53 }); 51 54 }