1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
//
// //use ravif::*;
// use image::{open};
// use load_image::export::rgb::RGBA;
//
// pub async fn main() -> std::io::Result<()> {
// let img = open("/Users/wangruihong/Downloads/60aa22ef9a5569340bd73a547d6d38a31a6314e34dbc04418189397bbb5a9bfb.gif").unwrap();
//
// // Convert the image to RGB.
// let rgba_img = img.to_rgba8();
//
// // Get the dimensions of the image.
// let (width, height) = rgba_img.dimensions();
// println!("Width: {}, Height: {}", width, height);
//
// let mut raw_pixels: Vec<RGBA<u8>> = Vec::new();
// for pixel in rgba_img.pixels() {
// let p = RGBA {
// r: pixel[0],
// g: pixel[1],
// b: pixel[2],
// a: pixel[3],
// };
// raw_pixels.push(p);
// }
//
// // Now you have the raw pixel data in the `raw_pixels` vector.
// // You can get a slice with the following:
// let raw_pixels_slice: &[RGBA<u8>] = &raw_pixels;
//
//
// let res = Encoder::new()
// .with_speed(10)
// .encode_rgba(Img::new(raw_pixels_slice, width as usize, height as usize)).unwrap();
// let _=std::fs::write("/Users/wangruihong/Downloads/hello.avif", res.avif_file);
// Ok(())
// }