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: Thepsdcrate’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§
- Blend
Mode Docs - Dummy struct to keep the main docs from being bloated. See LayerInfo::blend_mode.
- Layer
Info - Describes a single layer stack entry.
- Mask
Info - Metadata about where a mask attached to an object physically is and how to interpret it.
- PsdMetadata
- File-wide PSD header metadata.
Enums§
- Desc
Item - 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.
stridecan 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.