imageinfo

Crates.ioimageinfo
lib.rsimageinfo
version0.7.27
sourcesrc
created_at2022-01-28 07:05:40.670722
updated_at2024-12-02 10:57:34.986939
descriptionRust library to get image size and format without loading/decoding.
homepage
repositoryhttps://github.com/xiaozhuai/imageinfo-rs
max_upload_size
id522966
size62,943
Weihang Ding (xiaozhuai)

documentation

README

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 : )

Commit count: 83

cargo fmt