Skip to content

Commit

Permalink
Fix secondary palette sort
Browse files Browse the repository at this point in the history
This was only working if the input image was already indexed
  • Loading branch information
andrews05 committed Feb 20, 2024
1 parent 0608ab9 commit a426fab
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/reduction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,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 let Some(reduced) = reduced_to_indexed(&png, opts.grayscale_reduction) {
Expand All @@ -133,7 +134,8 @@ pub(crate) fn perform_reductions(

// Attempt to sort the palette using an alternative method
if !cheap && opts.palette_reduction && !deadline.passed() {
if let Some(reduced) = sorted_palette_battiato(&png) {
// Make sure we use the `indexed` var if it exists
if let Some(reduced) = sorted_palette_battiato(indexed.as_ref().unwrap_or(&png)) {
eval.try_image(Arc::new(reduced));
evaluation_added = true;
}
Expand Down

0 comments on commit a426fab

Please sign in to comment.