Prevent conversion to indexed when palette reduction is off
This commit is contained in:
parent
e4a7d0fd99
commit
6a1aa71691
2 changed files with 3 additions and 1 deletions
|
|
@ -298,6 +298,8 @@ The default value depends on the optimization level preset.")
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("no-palette-reduction")
|
Arg::new("no-palette-reduction")
|
||||||
.help("Do not change color palette")
|
.help("Do not change color palette")
|
||||||
|
.long_help("\
|
||||||
|
Do not convert to indexed and do not modify an existing color palette.")
|
||||||
.long("np")
|
.long("np")
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ pub(crate) fn perform_reductions(
|
||||||
// Attempt to reduce to indexed
|
// Attempt to reduce to indexed
|
||||||
// Keep the existing `png` var in case it is grayscale - we can test both for depth reduction later
|
// Keep the existing `png` var in case it is grayscale - we can test both for depth reduction later
|
||||||
let mut indexed = None;
|
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) {
|
if let Some(reduced) = reduced_to_indexed(&png, opts.grayscale_reduction) {
|
||||||
// Make sure the palette gets sorted (but don't bother evaluating both results)
|
// Make sure the palette gets sorted (but don't bother evaluating both results)
|
||||||
let new = Arc::new(sorted_palette(&reduced).unwrap_or(reduced));
|
let new = Arc::new(sorted_palette(&reduced).unwrap_or(reduced));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue