#image-format #size #format-file #filesize #jpeg #tiff #bmp

bin+lib imageinfo

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

23 releases

0.7.16 Feb 19, 2024
0.7.12 Jan 18, 2024
0.7.11 Dec 21, 2023
0.7.9 Nov 8, 2023
0.5.0 Feb 7, 2022

#2 in #bmp

Download history 88/week @ 2024-02-26 6/week @ 2024-03-04 22/week @ 2024-03-11 20/week @ 2024-03-18 46/week @ 2024-04-01 18/week @ 2024-05-13 23/week @ 2024-05-20 39/week @ 2024-05-27 14/week @ 2024-06-03 8/week @ 2024-06-10

85 downloads per month
Used in 2 crates

MIT license

44KB
1K 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
  • jp2
  • jpeg (jpg)
  • jpx
  • 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

~2.5–4MB
~75K SLoC