Crate rawpsd

Source
Expand description

rawpsd is a library that handles loading PSD data into a list of minimally-processed in-memory structs. It does not have any opinions about what features PSD files should or do use, or how to interpret those features. Compressed data is decompressed, and some redundant pieces of data like ascii and unicode names stored together are only returned once instead of twice, but aside from things like that, rawpsd is minimally opinionated and tries to just tell you what the PSD file itself says. For example, strings are left as strings instead of being transformed into enums.

Comparison with other crates:

  • psd: The psd crate’s API makes it impossible to figure out the exact layer group hierarchy, so you can only use it on very simple PSDs.
  • zune-psd: Doesn’t actually support the psd format, just gets the embedded thumbnail.

rawpsd draws a compatibility support line at Photoshop CS6, the last non-subscription version of Photoshop. Features only supported by newer versions are unlikely to be supported.

rawpsd currently only supports 8-bit RGB, CMYK, and Grayscale PSDs. This is the vast majority of PSD files that can be found in the wild. It does not yet support the large document PSB format variant.

rawpsd’s docs do not document the entire PSD format, not even its capabilities. You will need to occasionally reference https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/ and manually poke at PSD files in a hex editor to take full advantage of rawpsd.

You want parse_layer_records and parse_psd_metadata.

Example:

let mut file = std::fs::File::open("data/test.psd").expect("Failed to open test.psd");
let mut data = Vec::new();
file.read_to_end(&mut data).expect("Failed to read file");

if let Ok(layers) = parse_layer_records(&data)
{
    for mut layer in layers
    {
        layer.image_data_rgba = vec!();
        println!("{:?}", layer);
    }
}

Structs§

BlendModeDocs
Dummy struct to keep the main docs from being bloated. See LayerInfo::blend_mode.
LayerInfo
Describes a single layer stack entry.
MaskInfo
Metadata about where a mask attached to an object physically is and how to interpret it.
PsdMetadata
File-wide PSD header metadata.

Enums§

DescItem
PSD Class Descriptor object data. Only used by certain PSD features.

Functions§

append_img_data
Decompress a packbits image data buffer into a vec, appending to the vec.
copy_img_data
Decompress a packbits image data buffer into a slice, writing into the slice in-place. stride can be used to control how far apart to write each byte.
parse_layer_records
Parses the layer records out of a PSD file, producing a bottom-to-top list.
parse_psd_metadata
Parses just the frontmost metadata at the start of a PSD file.