2 unstable releases

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

#123 in #decoder

Download history 55/week @ 2024-07-22 230/week @ 2024-07-29 156/week @ 2024-08-05 162/week @ 2024-08-12 5/week @ 2024-08-19 80/week @ 2024-08-26 26/week @ 2024-09-02 13/week @ 2024-09-09 404/week @ 2024-09-16 45/week @ 2024-09-23 168/week @ 2024-09-30 628/week @ 2024-10-07 9/week @ 2024-10-14 314/week @ 2024-10-28 225/week @ 2024-11-04

1,036 downloads per month
Used in zune-image

MIT OR Apache-2.0 OR Zlib

120KB
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