Rename KEEP_SAFE to DISPLAY

This commit is contained in:
Andrew 2023-12-11 08:31:07 +13:00
parent d7f9c81a28
commit 60243fe932
2 changed files with 6 additions and 6 deletions

View file

@ -76,7 +76,7 @@ pub enum StripChunks {
None,
/// Remove specific chunks
Strip(IndexSet<[u8; 4]>),
/// Remove all chunks that won't affect rendering
/// Remove all chunks that won't affect image display
Safe,
/// Remove all non-critical chunks except these
Keep(IndexSet<[u8; 4]>),
@ -85,8 +85,8 @@ pub enum StripChunks {
}
impl StripChunks {
/// List of chunks that will be kept when using the `Safe` option
pub const KEEP_SAFE: [[u8; 4]; 7] = [
/// List of chunks that affect image display and will be kept when using the `Safe` option
pub const DISPLAY: [[u8; 4]; 7] = [
*b"cICP", *b"iCCP", *b"sRGB", *b"pHYs", *b"acTL", *b"fcTL", *b"fdAT",
];
@ -95,7 +95,7 @@ impl StripChunks {
StripChunks::None => true,
StripChunks::Keep(names) => names.contains(name),
StripChunks::Strip(names) => !names.contains(name),
StripChunks::Safe => Self::KEEP_SAFE.contains(name),
StripChunks::Safe => Self::DISPLAY.contains(name),
StripChunks::All => false,
}
}

View file

@ -163,7 +163,7 @@ CAUTION: 'all' will convert APNGs to standard PNGs.
Note that 'bKGD', 'sBIT' and 'hIST' will be forcibly stripped if the color type or bit \
depth is changed, regardless of any options set.",
StripChunks::KEEP_SAFE
StripChunks::DISPLAY
.iter()
.map(|c| String::from_utf8_lossy(c))
.collect::<Vec<_>>()
@ -632,7 +632,7 @@ fn parse_opts_into_struct(
})
.collect::<Result<IndexSet<_>, _>>()?;
if keep_display {
names.extend(StripChunks::KEEP_SAFE.iter().cloned());
names.extend(StripChunks::DISPLAY.iter().cloned());
}
opts.strip = StripChunks::Keep(names)
}