feat: display file size

This commit is contained in:
electria 2026-07-31 17:23:29 -07:00
commit 6fa0e29eae
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs
3 changed files with 16 additions and 1 deletions

7
Cargo.lock generated
View file

@ -1905,6 +1905,7 @@ dependencies = [
"image", "image",
"jxl-oxide", "jxl-oxide",
"rfd", "rfd",
"size",
"zip", "zip",
] ]
@ -3787,6 +3788,12 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"
[[package]]
name = "size"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b6709c7b6754dca1311b3c73e79fcce40dd414c782c66d88e8823030093b02b"
[[package]] [[package]]
name = "skrifa" name = "skrifa"
version = "0.37.0" version = "0.37.0"

View file

@ -7,6 +7,7 @@ license = "AGPL-3.0-or-later"
[dependencies] [dependencies]
dirs = "6.0.0" dirs = "6.0.0"
rfd = "0.17.2" rfd = "0.17.2"
size = "0.5.0"
zip = "8.6.0" zip = "8.6.0"
[dependencies.iced] [dependencies.iced]

View file

@ -2,6 +2,7 @@ use std::{
borrow::Cow, borrow::Cow,
env, env,
ffi::OsStr, ffi::OsStr,
os::unix::fs::MetadataExt,
path::{Path, PathBuf}, path::{Path, PathBuf},
}; };
@ -11,6 +12,7 @@ use iced::{
theme, widget, window, theme, widget, window,
}; };
use image::{EncodableLayout, RgbaImage, imageops}; use image::{EncodableLayout, RgbaImage, imageops};
use size::Size;
mod kra; mod kra;
mod utils; mod utils;
@ -179,10 +181,15 @@ impl State {
fn load_image(&mut self, path: impl AsRef<Path>) -> Result<Task<Message>, String> { fn load_image(&mut self, path: impl AsRef<Path>) -> Result<Task<Message>, String> {
utils::load_image(&path).map(|image| { utils::load_image(&path).map(|image| {
self.info = Some(format!( self.info = Some(format!(
"{} {}x{}", "{} {} {}x{}",
path.as_ref() path.as_ref()
.file_name() .file_name()
.map_or(Cow::Borrowed("[no file]"), OsStr::to_string_lossy), .map_or(Cow::Borrowed("[no file]"), OsStr::to_string_lossy),
path.as_ref()
.metadata()
.map_or(Cow::Borrowed("[no size]"), |m| Cow::Owned(
Size::from_bytes(m.size()).to_string()
)),
image.width(), image.width(),
image.height(), image.height(),
)); ));