use cowgen::*; use std::{ fs::{self, File}, io::Write, }; #[test] fn test_overlay_text_and_image() { println!("{}", std::env::current_dir().unwrap().to_str().unwrap()); let out = Template::new( include_bytes!("assets/cow.png").to_vec(), vec![ Element::new( Media::Text(Text::new( "Hello", "tests/assets/OpenSans-ExtraBold.ttf", 20.0, (0, 0, 0, 128), )), (0, 0), (64, 64), ), Element::new( Media::Image(include_bytes!("assets/mariah.jpg").to_vec()), (400, 400), (800, 200), ), ], ) .unwrap() .produce() .unwrap(); let mut f = File::create("tests/out/one.png").unwrap(); f.write_all(&out).unwrap(); f.flush().unwrap(); let actual = fs::read("tests/out/one.png").unwrap(); let expected = include_bytes!("expected/one.png").to_vec(); assert_eq!(expected, actual); }