Skip to content

Commit

Permalink
add image dimension when showing images
Browse files Browse the repository at this point in the history
update version of next in use
  • Loading branch information
visnkmr committed May 26, 2024
1 parent b171afa commit 3e497df
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"lodash.take": "^4.1.1",
"lucide-react": "^0.295.0",
"luxon": "^3.3.0",
"next": "^14.0.4",
"next": "*",
"next-sitemap": "^4.1.8",
"next-themes": "^0.2.1",
"radix-ui": "^1.0.1",
Expand Down
11 changes: 9 additions & 2 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ tauri = { version = "1.5.4", features = ["devtools", "fs-read-file", "os-all", "
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
rayon="1.7.0"
# image = "0.24.6"
# image = "0.25.1"
# image = {git="https://codeberg.org/visnk/image-rs.git"}
reqwest="0.11.24"
tokio= {version="1.36.0",features= ["macros"] }
Expand All @@ -49,6 +49,7 @@ rustc-hash="1.1.0"
# walkdir="2.3.3"
filesize = "0.2.0"
# jwalk="0.8.1"
imagesize="0.12.0"
# dua-cli="2.19.2"
# dirscan="1.4.1"
# markdown= {git="https://github.com/wooorm/markdown-rs.git"}
Expand Down
29 changes: 23 additions & 6 deletions src-tauri/src/fileitem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::os::windows::fs::OpenOptionsExt;
// use image::{GenericImageView, io::Reader};
use rayon::prelude::*;
use serde_json::json;
use tauri::{Manager, State, Window};
use tauri::{api::file, Manager, State, Window};
// use walkdir::{WalkDir, DirEntry};

use crate::{
Expand Down Expand Up @@ -88,12 +88,26 @@ pub fn populatefileitem(
let is_dir = fs::metadata(path).map(|m| m.is_dir()).unwrap_or(false); // check if folder
let mut folderloc = 0;
let mut filetype = "Folder".to_string();
let mut filedime=String::new();
// let mut filesetcollection=HashSet::new();
let issymlink = path.is_relative() || path.is_symlink();
if (issymlink) {
filetype += "symlink";
}
if !path.is_dir() {
#[cfg(unix)]
if let Ok(img) =
imagesize::size(path)
// image::image_dimensions(path)
// reader.into_dimensions()
{

println!("image found");
// let (width, height) = img;
filedime= format!("{} x {}", img.width, img.height).to_string();
println!("{}",filedime);
// println!("{filedime}")
}
//modify here to add more extensions to list linecount
match (path.extension()) {
Some(g) => {
Expand Down Expand Up @@ -123,8 +137,10 @@ pub fn populatefileitem(
.open(path)
.unwrap(),
);
println!("image found");

// #[cfg(unix)]
// let f =
// let f =

// BufReader::new(
// OpenOptions::new()
Expand All @@ -134,15 +150,16 @@ pub fn populatefileitem(
// .open(path).unwrap());

// let mut reader = image::io::Reader::new(f);
// // println!("image found");

// if let Ok(img) =
// // image::image_dimensions(path)
// reader.into_dimensions()
// {

// println!("image found");
// let (width, height) = img;
// filedime=
// format!("{} x {}", width, height).to_string();
// filedime= format!("{} x {}", width, height).to_string();
// println!("{}",filedime);
// // println!("{filedime}")
// }
}
Expand Down Expand Up @@ -174,7 +191,7 @@ pub fn populatefileitem(
let tr;
let (lmdate, timestamp) = lastmodified(&pathtf);
FileItem {
name: name.clone(),
name: name.clone()+" "+&filedime,
path: pathtf.clone(),
is_dir,
size: {
Expand Down

0 comments on commit 3e497df

Please sign in to comment.