From a1be18b5483c979f80f2111845dafbcac81ef02a Mon Sep 17 00:00:00 2001 From: "A. Molzer" <5550310+197g@users.noreply.github.com> Date: Thu, 10 Jul 2025 18:00:16 +0200 Subject: [PATCH] Add subsubifds test file --- tests/COPYRIGHT | 4 ++++ tests/subsubifds.rs | 33 +++++++++++++++++++++++++++++++++ tests/subsubifds.tif | Bin 0 -> 4774 bytes 3 files changed, 37 insertions(+) create mode 100644 tests/COPYRIGHT create mode 100644 tests/subsubifds.rs create mode 100644 tests/subsubifds.tif diff --git a/tests/COPYRIGHT b/tests/COPYRIGHT new file mode 100644 index 0000000..064bfe0 --- /dev/null +++ b/tests/COPYRIGHT @@ -0,0 +1,4 @@ +subsubifd.tif: + url: https://data.kitware.com/api/v1/file/hashsum/sha512/372ca32735c8a8fdbe2286dabead9e779da63f10ba81eda84625e5273f76d74ca1a47a978f67e9c00c12f7f72009c7b2c07a641e643bb0c463812f4ae7f15d6e/download + credit: https://github.com/DigitalSlideArchive/tifftools/commit/4d00c70dbce828262f86c1431f7c66b1748965ac + license: CC0 diff --git a/tests/subsubifds.rs b/tests/subsubifds.rs new file mode 100644 index 0000000..fc72e8c --- /dev/null +++ b/tests/subsubifds.rs @@ -0,0 +1,33 @@ +use tiff::{decoder::Decoder, tags::IfdPointer}; + +// This file has the following IFD structure: +// +// ``` +// IFD -> IFD -> IFD +// |-> IFD +// |-> IFD -> IFD +// | \-> IFD -> IFD +// \-> IFD +// ``` +// +// where the main chain of IFD has 3 images, the second of which has several sub-IFDs and some have +// more nested IFDs. +const TEST_IMAGE_SUBIFD: &str = "./tests/subsubifds.tif"; +use std::fs::File; + +#[test] +fn decode_seek_chain() { + let file = File::open(TEST_IMAGE_SUBIFD).expect("Cannot open test image"); + let mut decoder = Decoder::new(file).expect("Invalid format to create decoder"); + + decoder.next_image().unwrap(); + decoder.next_image().unwrap(); + assert!(!decoder.more_images()); + + // Ensure we can seek, to do this again. + decoder.seek_to_image(0) + .expect("Failed to seek to first image"); + decoder.next_image().unwrap(); + decoder.next_image().unwrap(); + assert!(!decoder.more_images()); +} diff --git a/tests/subsubifds.tif b/tests/subsubifds.tif new file mode 100644 index 0000000000000000000000000000000000000000..51c99d56e82a447e275e7a8d2d378260c3db279b GIT binary patch literal 4774 zcmd^Ddr(tn7XNNS5`;hy5JG89e2uQ60=`!P(h42!PT$1H7~qTIx) zsI(GsTHOuxF08VDgvQ{LXVE=?IpHs^N(om|xfx405+7F*Z`-igeto^<`C z>pEL5<+#-bb#PAo{^&5~V?Fbh(0)aIew&nyR&U*4aL!P!oI@DuMtsA@&H4Ku)-=Pv z0N^BLZ-rvvxT1XIBah0&HO52G36o(z7tYo^q_<0d zj8hQOoZKku-BIv|IzmRaZ~+5H!*T10XrG~-Ler4fh(A6N6e0NI{vC)zVecCyzNI{{ z0I>kydE+DOfA5WBaX)sg;!g?4u--X@45z$^7h*G7pvRmM{n)iuh{rmih+Xq*&|aWK zy?dxb9Nv%X5x?lM&IFHjUiEnYYY)5>vC9vI&oTu4!~2ts z72@J6yK7b9mKZ1aCKUcEA^&BTq^!Rj?;qtG`YhD58O**DCAmpIzm&7e!5poPZI~y zi0*DU3!lScXy{RGi&M>$9Lw4jraa}R8C`P9k@VqVi1^(DmZp{6F~$+X;?5pur>7VT zcKrrq5llVX>1B$YlOVA6bGtoD{`$7_A;B~IlJ$~pTq!i{z9A!97nQeoNX9JG6tXhG zRIVFByCK+;NA0=TubFjsBq1z-R$}U;){IlKFKCj)))Dg>X;vk-%<TRF}dyX#*d?oHoRt}bfLVX$y^{pzq`I_rUlsZN-guHY1@``~9892%o5hBIZ zvIp%T+76QS9QCpVz43ZEg5CzBm$NvZ*GmOrUN7Gu9*SN{uqN@TX6~bj-cv6VTE+1p zp?aJ82U*llx8Rb-R9=}H%%)eRHbJ-WW}V?ewO2b-9)=%jt+G38PsAoBCDIOSrYBmR z*{n)ioJ9^dSN&Wk03Ou>Lmj9VWhGz3#FC-RRNQ2eKqfZj?(ZXe^a^t|bbz*2mpuu$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