Skip to content

Commit 1737b8f

Browse files
committed
Keep fcTL after PLTE
1 parent 90ceef9 commit 1737b8f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/png/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,11 @@ impl PngData {
186186
// Ancillary chunks - split into those that come before IDAT and those that come after
187187
let mut aux_split = self.aux_chunks.split(|c| &c.name == b"IDAT");
188188
let aux_pre = aux_split.next().unwrap();
189+
// Many chunks need to be before PLTE, so write all except those that explicitly need to be after
190+
// Note: fcTL does not strictly need to be after PLTE but some software may expect it
189191
for chunk in aux_pre
190192
.iter()
191-
.filter(|c| !(&c.name == b"bKGD" || &c.name == b"hIST" || &c.name == b"tRNS"))
193+
.filter(|c| !matches!(&c.name, b"bKGD" | b"hIST" | b"tRNS" | b"fcTL"))
192194
{
193195
write_png_block(&chunk.name, &chunk.data, &mut output);
194196
}
@@ -223,7 +225,7 @@ impl PngData {
223225
// Special ancillary chunks that need to come after PLTE but before IDAT
224226
for chunk in aux_pre
225227
.iter()
226-
.filter(|c| &c.name == b"bKGD" || &c.name == b"hIST" || &c.name == b"tRNS")
228+
.filter(|c| matches!(&c.name, b"bKGD" | b"hIST" | b"tRNS" | b"fcTL"))
227229
{
228230
write_png_block(&chunk.name, &chunk.data, &mut output);
229231
}

0 commit comments

Comments
 (0)