#heic #avif #heif #dds #cur #image #bmp #gif #hdr #size

bin+lib imageinfo

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

12 releases (6 breaking)

new 0.7.5 Jul 4, 2022
0.7.4 Jun 23, 2022
0.6.0 Jun 2, 2022
0.5.0 Feb 7, 2022
0.1.0 Jan 28, 2022
Download history 26/week @ 2022-03-16 10/week @ 2022-03-23 2/week @ 2022-03-30 5/week @ 2022-04-06 3/week @ 2022-04-13 30/week @ 2022-04-27 26/week @ 2022-05-04 75/week @ 2022-05-11 23/week @ 2022-05-18 25/week @ 2022-05-25 70/week @ 2022-06-01 14/week @ 2022-06-08 4/week @ 2022-06-15 114/week @ 2022-06-22 19/week @ 2022-06-29

151 downloads per month

MIT license

42KB
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.

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...

Example

[dependencies]
imageinfo = "0.7.5"
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

~1–1.3MB
~38K SLoC