diff --git a/src/png.rs b/src/png.rs index 276c5183..13f538b1 100644 --- a/src/png.rs +++ b/src/png.rs @@ -239,6 +239,8 @@ impl PngData { }; if header.0 == "IDAT" { idat_headers.extend(header.1); + } else if header.0 == "acTL" { + return Err(PngError::new("APNG files are not (yet) supported")); } else { aux_headers.insert(header.0, header.1); } diff --git a/tests/files/apng_file.png b/tests/files/apng_file.png new file mode 100644 index 00000000..1b35084a Binary files /dev/null and b/tests/files/apng_file.png differ diff --git a/tests/lib.rs b/tests/lib.rs index 681e5723..f2619849 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -31,6 +31,19 @@ fn optimize_from_memory_corrupted() { assert!(result.is_err()); } +#[test] +fn optimize_from_memory_apng() { + let mut in_file = File::open("tests/files/apng_file.png").unwrap(); + let mut in_file_buf: Vec = Vec::new(); + in_file.read_to_end(&mut in_file_buf).unwrap(); + + let mut opts: oxipng::Options = Default::default(); + opts.verbosity = Some(1); + + let result = oxipng::optimize_from_memory(&in_file_buf, &opts); + assert!(result.is_err()); +} + #[test] fn optimize() { let mut opts: oxipng::Options = Default::default(); @@ -48,3 +61,12 @@ fn optimize_corrupted() { let result = oxipng::optimize(Path::new("tests/files/corrupted_header.png"), &opts); assert!(result.is_err()); } + +#[test] +fn optimize_apng() { + let mut opts: oxipng::Options = Default::default(); + opts.verbosity = Some(1); + + let result = oxipng::optimize(Path::new("tests/files/apng_file.png"), &opts); + assert!(result.is_err()); +}