From 25e147f6a0adf6b27cdb40c8027863b77deab405 Mon Sep 17 00:00:00 2001 From: andrews05 Date: Tue, 7 Apr 2026 09:14:22 +1200 Subject: [PATCH] Prevent conversion to indexed when palette reduction is off (#802) --- src/cli.rs | 2 ++ src/reduction/mod.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cli.rs b/src/cli.rs index e0b45296..df9cb96a 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -298,6 +298,8 @@ The default value depends on the optimization level preset.") .arg( Arg::new("no-palette-reduction") .help("Do not change color palette") + .long_help("\ +Do not convert to indexed and do not modify an existing color palette.") .long("np") .action(ArgAction::SetTrue), ) diff --git a/src/reduction/mod.rs b/src/reduction/mod.rs index c8444fff..5881a917 100644 --- a/src/reduction/mod.rs +++ b/src/reduction/mod.rs @@ -118,7 +118,7 @@ pub(crate) fn perform_reductions( // Attempt to reduce to indexed // Keep the existing `png` var in case it is grayscale - we can test both for depth reduction later let mut indexed = None; - if opts.color_type_reduction && !deadline.passed() { + if opts.color_type_reduction && opts.palette_reduction && !deadline.passed() { if let Some(reduced) = reduced_to_indexed(&png, opts.grayscale_reduction) { // Make sure the palette gets sorted (but don't bother evaluating both results) let new = Arc::new(sorted_palette(&reduced).unwrap_or(reduced));