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:

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

$ cargo run -q --example imsz -- --help imsz 0.2.0 Paulo Scardine paulo@scardine.com.br, Mathias Panzenböck grosser.meister.morti@gmx.net

USAGE: imsz [FILES]...

ARGS: ...

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

The relevant parts:

```Rust use imsz::imsz;

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

// alternatively if you have something implementing Read and Seek: use imsz::imszfromreader;

let mut file = BufReader::new(File::open(fname)?); let info = imszfromreader(&mut file)?; ```

Supported File Formats

No guarantees of correct or complete implementation are made.

Related Work