Crates.io | thumbcache |
lib.rs | thumbcache |
version | 0.2.0 |
source | src |
created_at | 2024-08-27 13:08:49.228683 |
updated_at | 2024-09-27 17:30:58.641468 |
description | Get file thumbnail on Windows |
homepage | https://github.com/yhdgms1/thumbcache |
repository | https://github.com/yhdgms1/thumbcache |
max_upload_size | |
id | 1353373 |
size | 10,524 |
Uses Windows thumbcache to get bmp preview for a file.
When trying to get preview from file that is not an image (.zip or .exe) will throw error. May also throw error if preview does not exists. So it's better to check for errors rather than relying on .unwrap()
or ?
syntax.
use std::io::{Error, Write};
pub fn main() -> Result<(), Error> {
let bmp = thumbcache::get_bmp(r"C:\path-to-file.jpeg", 96, 96)?;
let mut file_out = std::fs::File::create("./out.bmp")?;
let _ = file_out.write_all(&bmp);
Ok(())
}
When I was writing this thing I used sources below. Also, I have used ChatGPT because I am not a Rust developer in first place and not very familiar with C or WinAPI. Worth mentioning in my opinion.
https://stackoverflow.com/questions/14207618/get-bytes-from-hbitmap
https://stackoverflow.com/questions/21751747/extract-thumbnail-for-any-file-in-windows