Skip to main content

Crate ag_psd

Crate ag_psd 

Source
Expand description

§ag-psd

Read and write Adobe Photoshop (.psd / .psb) files in pure Rust.

This crate is a from-scratch Rust port of the ag-psd TypeScript library. The data model mirrors the upstream structures, so anyone familiar with the JS API will recognize psd::Psd, psd::Layer, psd::ReadOptions and psd::WriteOptions.

§Quick start

use ag_psd::{read_psd, write_psd};
use ag_psd::psd::{ReadOptions, WriteOptions};

// Read
let bytes = std::fs::read("input.psd").unwrap();
let psd = read_psd(&bytes, &ReadOptions::default()).unwrap();
println!("{}x{}, {} top-level layers", psd.width, psd.height,
         psd.children.as_ref().map_or(0, |c| c.len()));

// Write
let out = write_psd(&psd, &WriteOptions::default());
std::fs::write("output.psd", out).unwrap();

The most important entry points are read_psd and write_psd; the document/layer types live in the psd module. See the README.md and docs/usage.md in the repository for a detailed guide.

§Vibe-coded port

This port was written almost entirely by Claude (Anthropic), using the upstream TypeScript source as the specification and its test fixtures as the oracle. See the README for the full status and known limitations.

Re-exports§

pub use engine_data::parse_engine_data;
pub use engine_data::serialize_engine_data;
pub use engine_data::EngineDataError;
pub use engine_data::EngineValue;
pub use engine_data2::decode_engine_data2;
pub use abr::read_abr;
pub use abr::Abr;
pub use abr::Brush;
pub use abr::BrushShape;
pub use abr::ReadAbrOptions;
pub use abr::SampleInfo;
pub use ase::read_ase;
pub use ase::write_ase;
pub use ase::Ase;
pub use ase::AseColor;
pub use ase::AseColorValue;
pub use ase::AseEntry;
pub use ase::AseGroup;
pub use csh::read_csh;
pub use csh::write_csh;
pub use csh::Csh;
pub use csh::CshShape;
pub use reader::read_psd;
pub use writer::write_psd;
pub use writer::write_psd_to_writer;

Modules§

abr
additional_info
ase
csh
descriptor
effects_helpers
engine_data
engine_data2
helpers
image_resources
initialize_canvas
jpeg
psd
reader
Endianness
text
utf8
writer