Prevent conversion to indexed when palette reduction is off (#802)
This commit is contained in:
parent
a75343800c
commit
25e147f6a0
2 changed files with 3 additions and 1 deletions
|
|
@ -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),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Reference in a new issue