2 unstable releases

0.5.0-rc0 Apr 7, 2024
0.4.0 Nov 16, 2023

#857 in Images

Download history 5/week @ 2024-02-17 22/week @ 2024-02-24 14/week @ 2024-03-02 24/week @ 2024-03-09 627/week @ 2024-03-16 275/week @ 2024-03-23 241/week @ 2024-03-30 480/week @ 2024-04-06

1,635 downloads per month
Used in zune-image

MIT OR Apache-2.0 OR Zlib

115KB
2K SLoC

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

  1. 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


lib.rs:

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..

obligatory photoshop dunking

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(())
}

Dependencies