MCPcopy Index your code
hub / github.com/Roughsketch/imagesize

github.com/Roughsketch/imagesize @v0.14.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.14.0 ↗ · + Follow
162 symbols 293 edges 51 files 10 documented · 6% 47 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

crates.io version docs-badge

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:

[dependencies]
imagesize = "0.14"

Supported Image Formats

  • Aseprite
  • Avif
  • BMP
  • DDS
  • EXR
  • Farbfeld
  • GIF
  • HDR
  • HEIC / HEIF
  • ICO*
  • ILBM (IFF)
  • JPEG
  • JPEG XL
  • KTX2
  • PNG
  • PNM (PBM, PGM, PPM)
  • PSD / PSB
  • QOI
  • TGA
  • TIFF
  • VTF
  • 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

match imagesize::size("example.webp") {
    Ok(size) => println!("Image dimensions: {}x{}", size.width, size.height),
    Err(why) => println!("Error getting dimensions: {:?}", why)
}

From a vector

let data = vec![0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x64, 0x00, 0x64, 0x00];
match imagesize::blob_size(&data) {
    Ok(size) => println!("Image dimensions: {}x{}", size.width, size.height),
    Err(why) => println!("Error getting dimensions: {:?}", why),
}

Core symbols most depended-on inside this repo

size
called by 88
src/lib.rs
read_u32
called by 29
src/util.rs
read_u16
called by 23
src/util.rs
matches
called by 21
src/formats/vtf.rs
read_bits
called by 9
src/util.rs
read_u8
called by 6
src/util.rs
image_type
called by 5
src/lib.rs
read_i32
called by 4
src/util.rs

Shape

Function 151
Enum 5
Method 5
Class 1

Languages

Rust100%

Modules by API surface

tests/jxl.rs22 symbols
src/util.rs13 symbols
src/lib.rs13 symbols
tests/pnm.rs7 symbols
tests/jpeg.rs7 symbols
tests/webp.rs5 symbols
tests/tga.rs5 symbols
tests/blob.rs5 symbols
src/formats/webp.rs5 symbols
src/container/heif.rs5 symbols
tests/heic.rs4 symbols
tests/avif.rs4 symbols

For agents

$ claude mcp add imagesize \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page