#image-size #tiff #avif #jpeg #jpeg2000 #webp #cur #psd #bmp #qoi

bin+lib imageinfo

Rust library to get image size and format without loading/decoding

34 releases

0.7.27 Dec 2, 2024
0.7.26 Aug 5, 2024
0.7.24 Jul 31, 2024
0.7.16 Feb 19, 2024
0.5.0 Feb 7, 2022

#320 in Images

Download history 102/week @ 2025-07-16 119/week @ 2025-07-23 160/week @ 2025-07-30 106/week @ 2025-08-06 136/week @ 2025-08-13 86/week @ 2025-08-20 116/week @ 2025-08-27 126/week @ 2025-09-03 170/week @ 2025-09-10 86/week @ 2025-09-17 80/week @ 2025-09-24 44/week @ 2025-10-01 50/week @ 2025-10-08 30/week @ 2025-10-15 33/week @ 2025-10-22 31/week @ 2025-10-29

153 downloads per month
Used in 2 crates

MIT license

57KB
1.5K SLoC

imageinfo-rs

Rust library to get image size and format without loading/decoding.

The imageinfo don't get image format by file ext name, but infer by file header bytes and character.

A rewrite of c++ version imageinfo

Some test image files are from image-size. Many thanks to @netroy.

ci

Supported formats

  • avif
  • bmp
  • cur
  • dds
  • gif
  • hdr (pic)
  • heic (heif)
  • icns
  • ico
  • jpeg2000 code stream (j2k, j2c, jpc, jhc)
  • jpeg2000 (jp2, jpx, jph)
  • jpeg (jpg)
  • ktx
  • png
  • psd
  • qoi
  • svg
  • tga
  • tiff (tif)
  • webp
  • more coming...

Installation

See https://crates.io/crates/imageinfo

Example

use imageinfo::{ImageInfo};

fn main() {
    match ImageInfo::from_file_path("images/valid/bmp/sample.bmp") {
        Ok(info) => {
            println!("  - Ext       : {}", info.ext);
            println!("  - Full Ext  : {}", info.full_ext);
            println!("  - Size      : {}", info.size);
            println!("  - Mimetype  : {}", info.mimetype);
            println!("  - Entries   :");
            for size in info.entry_sizes.iter() {
                println!("    - {}", size);
            }
        }
        Err(err) => {
            println!("  - Err       : {}", err);
        }
    }
}

Pretty easy?

Don't be stingy with your star : )

Dependencies

~0.3–1MB
~22K SLoC