feat: display file size
This commit is contained in:
parent
18de039e77
commit
6fa0e29eae
3 changed files with 16 additions and 1 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
|
@ -1905,6 +1905,7 @@ dependencies = [
|
|||
"image",
|
||||
"jxl-oxide",
|
||||
"rfd",
|
||||
"size",
|
||||
"zip",
|
||||
]
|
||||
|
||||
|
|
@ -3787,6 +3788,12 @@ version = "0.1.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"
|
||||
|
||||
[[package]]
|
||||
name = "size"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b6709c7b6754dca1311b3c73e79fcce40dd414c782c66d88e8823030093b02b"
|
||||
|
||||
[[package]]
|
||||
name = "skrifa"
|
||||
version = "0.37.0"
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ license = "AGPL-3.0-or-later"
|
|||
[dependencies]
|
||||
dirs = "6.0.0"
|
||||
rfd = "0.17.2"
|
||||
size = "0.5.0"
|
||||
zip = "8.6.0"
|
||||
|
||||
[dependencies.iced]
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ use std::{
|
|||
borrow::Cow,
|
||||
env,
|
||||
ffi::OsStr,
|
||||
os::unix::fs::MetadataExt,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
|
|
@ -11,6 +12,7 @@ use iced::{
|
|||
theme, widget, window,
|
||||
};
|
||||
use image::{EncodableLayout, RgbaImage, imageops};
|
||||
use size::Size;
|
||||
|
||||
mod kra;
|
||||
mod utils;
|
||||
|
|
@ -179,10 +181,15 @@ impl State {
|
|||
fn load_image(&mut self, path: impl AsRef<Path>) -> Result<Task<Message>, String> {
|
||||
utils::load_image(&path).map(|image| {
|
||||
self.info = Some(format!(
|
||||
"{} {}x{}",
|
||||
"{} {} {}x{}",
|
||||
path.as_ref()
|
||||
.file_name()
|
||||
.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.height(),
|
||||
));
|
||||
|
|
|
|||
Loading…
Reference in a new issue