Commit a426fab 1 parent 0608ab9 commit a426fab Copy full SHA for a426fab
File tree 1 file changed +3
-1
lines changed
1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,7 @@ pub(crate) fn perform_reductions(
114
114
}
115
115
116
116
// Attempt to reduce to indexed
117
+ // Keep the existing `png` var in case it is grayscale - we can test both for depth reduction later
117
118
let mut indexed = None ;
118
119
if opts. color_type_reduction && !deadline. passed ( ) {
119
120
if let Some ( reduced) = reduced_to_indexed ( & png, opts. grayscale_reduction ) {
@@ -133,7 +134,8 @@ pub(crate) fn perform_reductions(
133
134
134
135
// Attempt to sort the palette using an alternative method
135
136
if !cheap && opts. palette_reduction && !deadline. passed ( ) {
136
- if let Some ( reduced) = sorted_palette_battiato ( & png) {
137
+ // Make sure we use the `indexed` var if it exists
138
+ if let Some ( reduced) = sorted_palette_battiato ( indexed. as_ref ( ) . unwrap_or ( & png) ) {
137
139
eval. try_image ( Arc :: new ( reduced) ) ;
138
140
evaluation_added = true ;
139
141
}
You can’t perform that action at this time.
0 commit comments