Skip to content
/ imsz Public
forked from scardine/imsz

Get image width and height reading as few bytes as possible.

License

Notifications You must be signed in to change notification settings

panzi/imsz

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

imsz

Test Status License ReferenceC API

Get width and height from an image file reading as few bytes as possible.

This is a fork of scardine/imsz that adds support for more file formats, but also breaks API compatibility in order to be more idiomatic Rust. It also provides a C library wrapper. For more information on how this started see the mentioned link.

The library itself has zero dependencies, but the example binary uses clap.

Usage

There is a simple example binary:

$ cargo run -q --example imsz testdata/image.gif
testdata/image.gif: GIF, 32 x 16

$ cargo run -q --example imsz -- --help
imsz 0.4.1
Paulo Scardine <[email protected]>, Mathias Panzenböck <[email protected]>

USAGE:
    imsz [FILES]...

ARGS:
    <FILES>...    

OPTIONS:
    -h, --help       Print help information
    -V, --version    Print version information

The relevant parts:

use imsz::imsz;

let info = imsz(filename)?;
println!("{}: {}, {} x {}", filename, info.format, info.width, info.height);
// testdata/image.gif: GIF, 32 x 16

// or for already opened files:
let info = imsz(File::open(filename)?);

// or for in memory buffers:
let info = imsz(b"\x89PNG\r\n\x1a\n...");

// or for *anything* implementing Read and Seek:
use imsz::imsz_from_reader;

let mut file = BufReader::new(File::open(filename)?);
let info = imsz_from_reader(&mut file)?;

Supported File Formats

  • AVIF
  • BMP
  • DDS
  • DIB
  • GIF
  • HEIC/HEIF
  • ICO
  • ILBM
  • JPEG
  • JPEG 2000
  • PCX
  • PNG
  • PSD
  • OpenEXR
  • QOI
  • TGA
  • TIFF
  • VTF
  • WEBP
  • XCF

No guarantees of correct or complete implementation are made.

Related Work

About

Get image width and height reading as few bytes as possible.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 66.3%
  • C 17.3%
  • Python 7.7%
  • Makefile 4.2%
  • HTML 2.6%
  • C++ 1.8%
  • CSS 0.1%