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 base = Box::new(include_bytes!("assets/cow.png").to_vec()); let font = Box::new(include_bytes!("assets/OpenSans-ExtraBold.ttf").to_vec()); let superimpose = Box::new(include_bytes!("assets/mariah.jpg").to_vec()); let out = produce( &base, vec![ Element::new( Media::Text(Text::new("Hello".to_string(), font, 20.0, (0, 0, 0, 128))), (0, 0), (64, 64), ), Element::new(Media::Image(superimpose), (400, 400), (800, 200)), ], ) .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); }