imagesize
Quickly probe the size of various image formats without reading the entire file.
The goal of this crate is to be able to read the dimensions of a supported image without loading unnecessary data, and without pulling in more dependencies. Most reads only require 16 bytes or less, and more complex formats take advantage of skipping junk data.
Usage
Add the following to your Cargo.toml:
[]
= "0.10"
Supported Image Formats
- BMP
- GIF
- HEIC / HEIF
- ICO*
- JPEG
- JPEG XL
- PNG
- PSD / PSB
- TIFF
- WEBP
If you have a format you think should be added, feel free to create an issue.
*ICO files can contain multiple images, imagesize
will give the dimensions of the largest one.
Examples
From a file
let = match size
From a vector
Where magic_partial_download
is a function that downloads a specified amount of bytes from a given url.
let data: = magic_partial_download;
let = match blob_size