From d049db9917678cad08e3d94c8d9276fbb9de00d1 Mon Sep 17 00:00:00 2001 From: gronod Date: Tue, 25 Aug 2026 10:10:31 +0100 Subject: [PATCH] feat(ui): add cross-platform TIFF-to-PNG preview conversion and set window dimensions (v0.1.13) --- package.json | 2 +- src-tauri/Cargo.toml | 8 ++++---- src-tauri/src/commands.rs | 26 ++++++++++++++++++++++++++ src-tauri/src/lib.rs | 1 + src-tauri/tauri.conf.json | 8 +++++--- src/js/printtarg.js | 4 ++-- 6 files changed, 39 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 773b906..5ad48c9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "iccery", "private": true, - "version": "0.1.12", + "version": "0.1.13", "type": "module", "scripts": { "tauri": "tauri" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 419ff98..d9ddbe1 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "iccery" -version = "0.1.12" -description = "A Tauri App" -authors = ["you"] +version = "0.1.13" +description = "Modern Printer Profiling UI frontend for ArgyllCMS" +authors = ["Gordon"] edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -24,6 +24,7 @@ serde_json = "1" tokio = { version = "1", features = ["process", "io-util", "sync", "time", "rt-multi-thread"] } tauri-plugin-dialog = "2.7.2" base64 = "0.22" +image = { version = "0.25", default-features = false, features = ["png", "tiff"] } [target.'cfg(windows)'.dependencies] windows = { version = "0.61", features = [ @@ -32,7 +33,6 @@ windows = { version = "0.61", features = [ "Win32_Graphics_Printing", "Win32_UI_WindowsAndMessaging", ] } -image = { version = "0.25", default-features = false, features = ["tiff"] } [profile.release] panic = "abort" diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 1d7fbb3..d80a23c 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -245,6 +245,32 @@ pub async fn read_file_base64(path: String) -> Result { Ok(base64::engine::general_purpose::STANDARD.encode(&bytes)) } +#[tauri::command] +pub async fn read_tiff_preview_png(path: String) -> Result { + use std::fs; + use std::io::Cursor; + use base64::Engine; + use image::ImageFormat; + + let file_bytes = fs::read(&path).map_err(|e| format!("Failed to read {}: {}", path, e))?; + let img = image::load_from_memory_with_format(&file_bytes, ImageFormat::Tiff) + .map_err(|e| format!("Failed to decode TIFF {}: {}", path, e))?; + + let max_dim = std::cmp::max(img.width(), img.height()); + let processed_img = if max_dim > 1200 { + img.resize(1200, 1200, image::imageops::FilterType::Lanczos3) + } else { + img + }; + + let mut png_bytes = Cursor::new(Vec::new()); + processed_img + .write_to(&mut png_bytes, ImageFormat::Png) + .map_err(|e| format!("Failed to encode PNG for {}: {}", path, e))?; + + Ok(base64::engine::general_purpose::STANDARD.encode(png_bytes.into_inner())) +} + #[derive(Debug, Deserialize, Serialize)] pub struct ChartreadConfig { pub basename: String, diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 282e023..1c9e97b 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -22,6 +22,7 @@ pub fn run() { commands::run_targen, commands::run_printtarg, commands::read_file_base64, + commands::read_tiff_preview_png, commands::run_chartread, commands::run_colprof, commands::run_profcheck, diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 217eb52..518296f 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "ICCery", - "version": "0.1.12", + "version": "0.1.13", "identifier": "com.gronod.iccery", "build": { "frontendDist": "../src" @@ -11,8 +11,10 @@ "windows": [ { "title": "ICCery", - "width": 800, - "height": 600 + "width": 1280, + "height": 800, + "minWidth": 1100, + "minHeight": 700 } ], "security": { diff --git a/src/js/printtarg.js b/src/js/printtarg.js index a826b4c..d6bc09a 100644 --- a/src/js/printtarg.js +++ b/src/js/printtarg.js @@ -511,9 +511,9 @@ export function initPrinttarg() { card.appendChild(label); try { - const base64Data = await invoke("read_file_base64", { path: filePath }); + const pngBase64 = await invoke("read_tiff_preview_png", { path: filePath }); const img = document.createElement("img"); - img.src = `data:image/tiff;base64,${base64Data}`; + img.src = `data:image/png;base64,${pngBase64}`; img.alt = page.filename; img.onerror = () => { img.remove(); -- 2.39.5