mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
* Load and save Photoshop Actions (.atn) (#219) - photocraft-psd: `atn` parser and writer for version-16 action sets, exact round trip, truncation/garbage safe, fuzz target and `atn_dump` example. Descriptor fix: `indx` and `Idnt` reference items carry a class before the number (real action files failed to parse). - photocraft-engine: `atn_cmds` maps 92 Photoshop events to commands and back (filters, adjustments per channel, image/canvas/crop/trim/rotate/flip/mode, make/set/select/delete/ hide/show/move/duplicate, fill/stroke, selection, clipboard, purge, profiles, play, stop). Other steps load as `actions.photoshopStep` (descriptor kept, written back by save, fails at playback by name); tool selections load switched off. Commands `actions.load`, `actions.save`, `actions.stopMessage`, `actions.photoshopStep`. `Action` gains `dialogs` and `set`. `layer` params accept a layer name, so loaded steps replay in any document. - UI: Actions panel menu › Load Actions… / Save Actions…; Photoshop steps labelled. - CLI: `batch --actions set.atn`. Automation policy covers the new path params. - Docs: file-format parity (.atn R/W), gaps G11, target-app parity, scorecard AUTO-219-2 partial, development guide. * Translate the Actions panel's Load/Save strings in every catalog The eight new panel strings (Load/Save Actions…, the loaded/saved counts, the kept-step label) were missing from all 19 catalogs; the languages that were complete are back at 100%. * Show the Actions entries in the default dock's panel menu The legacy dock renders its own group menu and only knew the Layers and Swatches entries, so Load Actions… and Save Actions… were missing there.
88 lines
3.2 KiB
Rust
88 lines
3.2 KiB
Rust
//! # photocraft-psd
|
|
//!
|
|
//! Faithful, lossless reader and writer for Adobe Photoshop PSD (version 1)
|
|
//! and PSB (version 2, "large document format") files.
|
|
//!
|
|
//! * [`PsdFile::from_bytes`] parses a file into a format-level model;
|
|
//! [`PsdFile::to_bytes`] writes it back. Unmodified files round-trip byte
|
|
//! for byte: channel data is kept in its original encoding, unknown tagged
|
|
//! blocks and resources are kept raw, and padding is preserved.
|
|
//! * Channel data is decoded lazily ([`ChannelData::decode`],
|
|
//! [`ImageData::decode`]) with all four compression methods supported for
|
|
//! both decoding and encoding.
|
|
//! * [`PsdBuilder`] constructs new files from RGBA/gray/CMYK buffers; the
|
|
//! caller supplies the merged composite (this crate never composites).
|
|
//! * [`descriptor`] parses and writes ActionDescriptors.
|
|
//!
|
|
//! Implemented clean-room from Adobe's public "Photoshop File Formats
|
|
//! Specification". Undocumented details that follow MIT-licensed psd-tools
|
|
//! or ag-psd behavior are noted in comments.
|
|
//!
|
|
//! The parser never panics on malformed input and enforces limits
|
|
//! (dimensions ≤ 300000, bounded allocations, bounded descriptor nesting).
|
|
//!
|
|
//! ```
|
|
//! use photocraft_psd::{LayerSpec, PixelData, PsdBuilder, PsdFile};
|
|
//!
|
|
//! let mut b = PsdBuilder::new(2, 1);
|
|
//! b.push_layer(LayerSpec::new("Red", 0, 0, 2, 1, PixelData::Rgba8(vec![255, 0, 0, 255, 255, 0, 0, 128])));
|
|
//! b.composite(PixelData::Rgba8(vec![255, 0, 0, 255, 255, 0, 0, 128]));
|
|
//! let bytes = b.to_bytes()?;
|
|
//!
|
|
//! let file = PsdFile::from_bytes(&bytes)?;
|
|
//! assert_eq!(file.to_bytes()?, bytes); // byte-stable
|
|
//! let layer = file.layer(0).unwrap();
|
|
//! assert_eq!(layer.name(), "Red");
|
|
//! assert_eq!(layer.rgba8()?.data[7], 128);
|
|
//! # Ok::<(), photocraft_psd::PsdError>(())
|
|
//! ```
|
|
#![forbid(unsafe_code)]
|
|
#![warn(missing_docs)]
|
|
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
|
|
|
pub mod abr;
|
|
pub mod aco;
|
|
pub mod ase;
|
|
pub mod atn;
|
|
pub mod blend;
|
|
pub mod builder;
|
|
pub mod compression;
|
|
pub mod descriptor;
|
|
pub mod error;
|
|
pub mod file;
|
|
pub mod filter_effects;
|
|
pub mod grd;
|
|
pub mod hdr;
|
|
pub mod header;
|
|
pub mod image_data;
|
|
mod io;
|
|
pub mod layer;
|
|
pub mod metadata;
|
|
pub mod path;
|
|
pub mod patterns;
|
|
pub mod pixels;
|
|
pub mod resources;
|
|
pub mod shc;
|
|
pub mod slices;
|
|
pub mod tagged;
|
|
#[cfg(any(test, feature = "testgen"))]
|
|
// Test-data generator (tests and fuzz seeds only): failing loudly is the point.
|
|
#[allow(clippy::expect_used)]
|
|
pub mod testgen;
|
|
pub mod tiff;
|
|
pub mod tree;
|
|
|
|
pub use blend::BlendMode;
|
|
pub use builder::{GroupSpec, LayerSpec, MaskSpec, PixelData, PsdBuilder};
|
|
pub use compression::{Compression, PlaneLayout};
|
|
pub use descriptor::{Descriptor, VersionedDescriptor};
|
|
pub use error::{PsdError, Result};
|
|
pub use file::{GlobalLayerMask, LayerInfoPlacement, PsdFile};
|
|
pub use header::{ColorMode, Header, Version};
|
|
pub use image_data::ImageData;
|
|
pub use layer::{BlendingRanges, ChannelData, LayerFlags, LayerInfo, LayerMask, LayerRecord, MaskData, MaskParameters, RealMask, Rect};
|
|
pub use pixels::{GrayImage, Layer, RgbaImage};
|
|
pub use resources::{ImageResource, ResolutionInfo, ResourceData};
|
|
pub use tagged::{BlockData, SectionDivider, SectionType, TaggedBlock};
|
|
pub use tree::LayerNode;
|