■ crop 함수를 사용해 이미지를 잘라내는 방법을 보여준다.
▶ 예제 코드 (RS)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
use image; use image::imageops; let mut source_dynamic_image : image::DynamicImage = image::open("d:/source.jpg").unwrap(); let subsidary_image : image::SubImage<&mut image::DynamicImage> = imageops::crop ( &mut source_dynamic_image, 50, 50, 200, 200 ); let target_image_buffer : image::ImageBuffer<image::Rgba<u8>, Vec<u8>> = subsidary_image.to_image(); target_image_buffer.save("d:/target.jpg").unwrap(); |
※ 참조 크레이트 : image