From 4c93d2459e2d698a1a2a6cbb9c4ca79181f12466 Mon Sep 17 00:00:00 2001 From: Pavel Rybalko Date: Thu, 27 Jul 2023 12:48:07 +0300 Subject: [PATCH] fix png compression setting --- Cargo.lock | 12 ++++++------ cli/Cargo.toml | 2 +- cli/src/source.rs | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dcd55dc28..473fcc0b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3504,9 +3504,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.103" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d03b412469450d4404fe8499a268edd7f8b79fecb074b0d812ad64ca21f4031b" +checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" dependencies = [ "itoa", "ryu", @@ -4273,18 +4273,18 @@ checksum = "95059e91184749cb66be6dc994f67f182b6d897cb3df74a5bf66b5e709295fd8" [[package]] name = "thiserror" -version = "1.0.43" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35fc5b8971143ca348fa6df4f024d4d55264f3468c71ad1c2f365b0a4d58c42" +checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.43" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" +checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" dependencies = [ "proc-macro2", "quote", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 2969ab523..f0170ea18 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -35,7 +35,7 @@ serde_json = "1.0" octocrab = "0.19.0" tokio = { version = "1", features = ["full"] } reqwest = { version = "0.11", features = ["json", "blocking"]} -png = "0.17.5" +png = "0.17.8" blake2-rfc = "0.2.18" # Hash table which preserves insertion order indexmap = {version="1", features=["serde"]} diff --git a/cli/src/source.rs b/cli/src/source.rs index 418788e78..4559f99bb 100644 --- a/cli/src/source.rs +++ b/cli/src/source.rs @@ -4,7 +4,6 @@ use std::io::BufWriter; use std::path::Path; use anyhow::Result; -use png::Encoder; use serde::{Deserialize, Serialize}; use sp_core::H256; use tempfile::tempdir; @@ -29,7 +28,7 @@ pub(crate) fn save_source_info(path: &Path, source: &Source) -> Result<()> { let out_path = tmp_dir.path().join("qr.apng"); let file = File::create(&out_path).unwrap(); let w = &mut BufWriter::new(file); - let mut encoder = Encoder::new(w, in_info.width, in_info.height); + let mut encoder = png::Encoder::new(w, in_info.width, in_info.height); encoder.set_color(in_info.color_type); encoder.set_depth(in_info.bit_depth); if let Some(palette) = in_info.palette.clone() { @@ -42,6 +41,7 @@ pub(crate) fn save_source_info(path: &Path, source: &Source) -> Result<()> { encoder.set_frame_delay(frame.delay_num, frame.delay_den)?; } encoder.add_ztxt_chunk(SOURCE.to_string(), serde_json::to_string(source)?)?; + encoder.set_compression(png::Compression::Best); let mut writer = encoder.write_header().unwrap();