Tweaked output size and speed

This commit is contained in:
Logan 2024-09-04 21:49:07 -05:00
parent f619f7dda8
commit bb28723ef0
3 changed files with 25 additions and 14 deletions

27
Cargo.lock generated
View file

@ -17,6 +17,12 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "adler2"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
[[package]] [[package]]
name = "ahash" name = "ahash"
version = "0.8.7" version = "0.8.7"
@ -127,7 +133,7 @@ dependencies = [
"cc", "cc",
"cfg-if", "cfg-if",
"libc", "libc",
"miniz_oxide", "miniz_oxide 0.7.1",
"object", "object",
"rustc-demangle", "rustc-demangle",
] ]
@ -416,7 +422,7 @@ dependencies = [
"flume", "flume",
"half", "half",
"lebe", "lebe",
"miniz_oxide", "miniz_oxide 0.7.1",
"rayon-core", "rayon-core",
"smallvec", "smallvec",
"zune-inflate", "zune-inflate",
@ -447,12 +453,12 @@ dependencies = [
[[package]] [[package]]
name = "flate2" name = "flate2"
version = "1.0.28" version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253"
dependencies = [ dependencies = [
"crc32fast", "crc32fast",
"miniz_oxide", "miniz_oxide 0.8.0",
] ]
[[package]] [[package]]
@ -1013,6 +1019,15 @@ dependencies = [
"simd-adler32", "simd-adler32",
] ]
[[package]]
name = "miniz_oxide"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1"
dependencies = [
"adler2",
]
[[package]] [[package]]
name = "mio" name = "mio"
version = "0.8.11" version = "0.8.11"
@ -1220,7 +1235,7 @@ dependencies = [
"crc32fast", "crc32fast",
"fdeflate", "fdeflate",
"flate2", "flate2",
"miniz_oxide", "miniz_oxide 0.7.1",
] ]
[[package]] [[package]]

View file

@ -15,12 +15,6 @@ bytemuck = {version="1.14", features=["derive"]}
futures-intrusive = "0.5" futures-intrusive = "0.5"
rust-cgi = "0.7" rust-cgi = "0.7"
[profile.dev]
opt-level=1
# codegen-units = 1
# lto = "fat"
[profile.release] [profile.release]
opt-level=3 opt-level=3
codegen-units = 1 codegen-units = 1

View file

@ -76,14 +76,16 @@ pub enum Error {
} }
pub async fn make_quickdraw() -> Option<Arc<Mutex<QuickDraw>>> { pub async fn make_quickdraw() -> Option<Arc<Mutex<QuickDraw>>> {
Some(Arc::new(Mutex::new(QuickDraw::new(512, 512, 1000).await?))) Some(Arc::new(Mutex::new(
QuickDraw::new(WIDTH as u32, HEIGHT as u32, 1000).await?,
)))
} }
pub async fn make_gif( pub async fn make_gif(
input: &[u8], input: &[u8],
draw: Arc<Mutex<QuickDraw>>, draw: Arc<Mutex<QuickDraw>>,
) -> Result<Vec<u8>, Error> { ) -> Result<Vec<u8>, Error> {
const STEP: usize = 20; const STEP: usize = 30;
const RADIUS: f32 = 7.0; const RADIUS: f32 = 7.0;
let image = image::io::Reader::new(Cursor::new(input.to_vec().as_slice())) let image = image::io::Reader::new(Cursor::new(input.to_vec().as_slice()))
.with_guessed_format() .with_guessed_format()