From 1de64a3818875947f7f1044b1d4cfdf271b04fd3 Mon Sep 17 00:00:00 2001 From: Genny Date: Sun, 21 Nov 2021 18:35:57 -0600 Subject: Bring gifprobe into this repository --- gifprobe/Cargo.toml | 14 +++++++ gifprobe/src/main.rs | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 gifprobe/Cargo.toml create mode 100644 gifprobe/src/main.rs (limited to 'gifprobe') diff --git a/gifprobe/Cargo.toml b/gifprobe/Cargo.toml new file mode 100644 index 0000000..75047b8 --- /dev/null +++ b/gifprobe/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "gifprobe" +version = "0.1.0" +authors = ["Genevive Alfirevic { + describe_image(&img); + img_count += 1; + } + gifed::block::Block::Extension(ext) => match ext { + gifed::block::extension::Extension::GraphicControl(gce) => { + hundreths += gce.delay_time() as usize; + + println!( + "Graphic Control Extension\n\tDelay Time {}\n\tDispose {}", + format!("{}s", gce.delay_time() as f32 / 100.0).yellow(), + gce.disposal_method().unwrap().yellow() + ) + } + gifed::block::extension::Extension::Looping(_) => todo!(), + gifed::block::extension::Extension::Comment(cmt) => { + println!("Comment Extension\n\tLength {}", cmt.len()) + } + gifed::block::extension::Extension::Application(app) => { + let auth = app.authentication_code(); + println!("Application Extension\n\tIdentifier {}\n\tAuthentication {:02X} {:02X} {:02X}",app.identifier().yellow(), auth[0].yellow(), auth[1].yellow(), auth[2].yellow()); + } + }, + } + } + + println!( + "{} is {}.{}s long and has {} frames", + file, + hundreths / 100, + hundreths % 100, + img_count + ); +} + +fn describe_image(bli: &IndexedImage) { + println!( + "Image\n\tOffset {}x{}\n\tDimensions {}x{}", + bli.image_descriptor.left.yellow(), + bli.image_descriptor.top.yellow(), + bli.image_descriptor.width.yellow(), + bli.image_descriptor.height.yellow(), + ); + + if bli.image_descriptor.color_table_present() { + println!( + "\tLocal Color Table Present {}\n\tLocal Color Table Size {}", + "Yes".green(), + bli.image_descriptor.color_table_size().green() + ); + } else { + println!( + "\tLocal Color Table Present {}\n\tLocal Color Table Size {}", + "No".red(), + bli.image_descriptor.color_table_size().red() + ); + } +} -- cgit 1.4.1-3-g733a5