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 0 | 0 | 0 | 0 |
0.14.0 - This version is safe to use because it has no known security vulnerabilities at this time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform
Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.
MIT - MIT LicenseQuickly 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.
Add the following to your Cargo.toml:
[dependencies]
imagesize = "0.14"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.
match imagesize::size("example.webp") {
Ok(size) => println!("Image dimensions: {}x{}", size.width, size.height),
Err(why) => println!("Error getting dimensions: {:?}", why)
}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),
}For texture container formats, you can detect both the container type and compression algorithm:
use imagesize::{image_type, ImageType, CompressionFamily};
let data = std::fs::read("texture.dds").unwrap();
match image_type(&data) {
Ok(ImageType::Dds(compression)) => {
println!("DDS texture with {:?} compression", compression);
}
Ok(ImageType::Pvrtc(compression)) => {
println!("PowerVR texture with {:?} compression", compression);
}
Ok(other) => println!("Other format: {:?}", other),
Err(e) => println!("Error: {:?}", e),
}Use helper methods to query compression information across different container formats:
use imagesize::{image_type, CompressionFamily};
let data = std::fs::read("texture.pvr").unwrap();
if let Ok(img_type) = image_type(&data) {
// Group related compression algorithms regardless of container
match img_type.compression_family() {
Some(CompressionFamily::Etc) => println!("ETC family compression"),
Some(CompressionFamily::BlockCompression) => println!("BC/DXT compression"),
Some(CompressionFamily::Pvrtc) => println!("PVRTC compression"),
_ => println!("Other or no compression"),
}
// Query container and compression properties
if img_type.is_block_compressed() {
println!("Uses block compression (BC1-7)");
}
if let Some(container) = img_type.container_format() {
println!("Container format: {}", container);
}
if img_type.is_multi_compression_container() {
println!("Container supports multiple compression types");
}
}