2 unstable releases
| 0.5.0-rc0 | Apr 7, 2024 |
|---|---|
| 0.4.0 | Nov 16, 2023 |
#3 in #psd
1,662 downloads per month
Used in 2 crates
120KB
2K
SLoC
A simple PSD decoder
This crate features a simple Photoshop PSD reader
What it means by simple
Photoshop is a complicated format, probably one of the most complicated format, this library doesn't claim to parse a lot of the images photoshop and it's derivatives will generate.
It does not check layers, doesn't like CMYKa images, only reads Grayscale, RGB and RGBA images
ignoring Dutone, Multichannel and a slew of other .PSD features I've never heard of.
It's as simple as it gets.
Sometimes that's all you need..
Example
- Reading a psd file
use zune_psd::errors::PSDDecodeErrors;
use zune_core::result::DecodingResult;
use zune_psd::PSDDecoder;
fn main()->Result<(),PSDDecodeErrors>{
use zune_core::bytestream::ZCursor;
let mut decoder = PSDDecoder::new(ZCursor::new(&[]));
let px = decoder.decode()?;
// we need to handle u8 and u16 since the decoder supports those depths
match px {
DecodingResult::U8(_) => {}
DecodingResult::U16(_) => {}
_=>unreachable!()
};
Ok(())
}
zune-psd
A simple photoshop reader.
This crate doesn't handle any fancy photoshop features, including layering, blending,metadata extraction and such, it simply copies some bytes it believes are the base layer hence it may not suit your needs
Usage
- First include it into your
Cargo.toml
cargo add zune-psd
or include it directory in your Cargo.toml
[dependencies]
zune-psd="0.4"
Then use either one of the decode_ variants to get pixel data
decode_raw will always return Vec<u8> while decode distinguishes return type via image
depth (either 8-bit or 16-bit)
Speed
The decoder is fairly fast, we don't do any fancy processing so there is no need to compare it with other crates (I'm not sure any supports full parsing), hence there are no benchmarks.
Security
The crate is fuzz tested in CI to ensure untrusted input does not cause a panic