feat(ui): add cross-platform TIFF-to-PNG preview conversion and set window dimensions (v0.1.13) #73

Merged
gronod merged 1 commits from fix/issue-58-png-previews-and-window-size into development 2026-08-25 10:21:04 +01:00
6 changed files with 39 additions and 10 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "iccery",
"private": true,
"version": "0.1.12",
"version": "0.1.13",
"type": "module",
"scripts": {
"tauri": "tauri"
+4 -4
View File
@@ -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"
+26
View File
@@ -245,6 +245,32 @@ pub async fn read_file_base64(path: String) -> Result<String, String> {
Ok(base64::engine::general_purpose::STANDARD.encode(&bytes))
}
#[tauri::command]
pub async fn read_tiff_preview_png(path: String) -> Result<String, String> {
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,
+1
View File
@@ -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,
+5 -3
View File
@@ -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": {
+2 -2
View File
@@ -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();