From 130e04d9a54f79003cfb8d60f554ff7097b0f188 Mon Sep 17 00:00:00 2001 From: Kornel Date: Sun, 22 Jan 2023 20:04:50 +0000 Subject: [PATCH] Lowest qualities limit number of colors --- src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 28500e9..b4753ab 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -411,6 +411,9 @@ impl Writer { 100 // the first frame is too important to ruin it }; liq.set_quality(0, quality)?; + if settings.s.quality < 50 { + liq.set_max_colors(u32::from(settings.s.quality * 2).max(16).next_power_of_two())?; + } let (buf, width, height) = image.into_contiguous_buf(); let mut img = liq.new_image(buf, width, height, 0.)?; // only later remapping tracks which area has been damaged by transparency