use-image 0.0.1

Practical image format and sizing helpers
Documentation
  • Coverage
  • 51.47%
    35 out of 68 items documented1 out of 35 items with examples
  • Size
  • Source code size: 28.01 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 869.9 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Documentation
  • RustUse/use-media
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • CloudBranch

RustUse use-image

Lightweight image utility primitives for format detection, image metadata classification, and common sizing helpers.

Warning: use-image is experimental and may change before 0.3.0.

Example

use use_image::{
    ImageFormat, ImageSize, detect_image_format_from_bytes, fit_within, image_mime_type,
    orientation,
};

let format = detect_image_format_from_bytes(b"\x89PNG\r\n\x1a\nrest");
let size = ImageSize::new(1600, 900);

assert_eq!(format, ImageFormat::Png);
assert_eq!(image_mime_type(format), Some("image/png"));
assert_eq!(orientation(size).to_string(), "landscape");
assert_eq!(fit_within(size, ImageSize::new(400, 400)), ImageSize::new(400, 225));

Scope

  • Image format detection from extensions, MIME types, and common magic bytes
  • Shared raster and vector classification helpers
  • Canonical image MIME and extension lookup
  • Basic image size, aspect ratio, orientation, and fit helpers
  • Small metadata structs for tooling, asset pipelines, and CLIs
  • Shared primitives for future crates such as use-png, use-jpeg, use-webp, use-gif, and use-ico

Non-goals

  • A full image decoder or encoder
  • Pixel manipulation or rendering
  • EXIF, ICC profile, or animation frame parsing
  • Compression or decompression
  • Filesystem I/O beyond what callers choose to do themselves

Relationship To use-svg

use-image handles shared image primitives and lightweight detection. use-svg stays focused on SVG-specific document helpers such as root extraction, viewBox parsing, normalization, and path utilities. Future format-specific crates can build on use-image for shared classification and metadata behavior while providing deeper format parsing where that remains practical.

License

Licensed under either the MIT license or the Apache License, Version 2.0, at your option.