about summary refs log tree commit diff
path: root/squash/src/image.rs
diff options
context:
space:
mode:
authorgennyble <gen@nyble.dev>2024-01-12 12:08:19 -0600
committergennyble <gen@nyble.dev>2024-01-12 12:08:19 -0600
commit0ec3c8d1c51ea2286e7762f3a3d1cbebd7700f50 (patch)
treeb51a97b76457299c0647232893a99991a9d17a6d /squash/src/image.rs
parent093bb9d6889f6e026f14edc04e2f79bdea3c0b56 (diff)
downloadcolorsquash-0ec3c8d1c51ea2286e7762f3a3d1cbebd7700f50.tar.gz
colorsquash-0ec3c8d1c51ea2286e7762f3a3d1cbebd7700f50.zip
squash: fix tolerance and add algorithm selection
Diffstat (limited to 'squash/src/image.rs')
-rw-r--r--squash/src/image.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/squash/src/image.rs b/squash/src/image.rs
index 098e8a0..5c7b45a 100644
--- a/squash/src/image.rs
+++ b/squash/src/image.rs
@@ -3,7 +3,7 @@ use std::{fs::File, io::BufWriter};
 use anyhow::{anyhow, bail};
 use camino::{Utf8Path, Utf8PathBuf};
 use colorsquash::Squasher;
-use gifed::writer::{GifBuilder, ImageBuilder};
+use gifed::{writer::ImageBuilder, Gif};
 use png::{ColorType, Decoder, Encoder};
 use zune_jpeg::{zune_core::colorspace::ColorSpace, JpegDecoder};
 
@@ -94,11 +94,10 @@ pub fn save_gif(
 	squasher: Squasher<u8>,
 	path: Utf8PathBuf,
 ) -> Result<(), anyhow::Error> {
-	GifBuilder::new(image.width as u16, image.height as u16)
-		.palette(squasher.palette_bytes().as_slice().try_into().unwrap())
-		.image(ImageBuilder::new(image.width as u16, image.height as u16).build(image.data)?)
-		.build()?
-		.save(path)?;
+	let mut gif = Gif::new(image.width as u16, image.height as u16);
+	gif.set_palette(Some(squasher.palette_gifed()));
+	gif.push(ImageBuilder::new(image.width as u16, image.height as u16).build(image.data)?);
+	gif.save(path)?;
 
 	Ok(())
 }