#thumbnail #preview #windows-file #windows

thumbcache

Get file thumbnail on Windows

4 releases

0.2.1 Jan 25, 2025
0.2.0 Sep 27, 2024
0.1.1 Aug 27, 2024
0.1.0 Aug 27, 2024

#7 in #thumbnail

Download history 23/week @ 2024-12-08 1/week @ 2024-12-15 51/week @ 2025-01-19 59/week @ 2025-01-26 12/week @ 2025-02-02

122 downloads per month

MIT license

6KB
62 lines

thumbcache

Uses Windows thumbcache to get bmp preview for a file.

Usage

When trying to get preview from file that is not an image (.zip or .exe) will gibe error. May also give error if preview does not exists.

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(())
}

Sources

https://stackoverflow.com/questions/14207618/get-bytes-from-hbitmap

https://stackoverflow.com/questions/21751747/extract-thumbnail-for-any-file-in-windows

Dependencies

~126MB
~2M SLoC