photocraft-affinity now reads native Affinity documents (container versions 8-12): the FAT and revision chain, stored/zlib/zstd entries with predictors and CRC checks, the tagged object stream in doc.dat, and the document model (pages, artboards, layers, groups, curves, geometric and compound shapes, fills, gradients, strokes, text, placed images, pixel layers, masks and embedded-document caches). Every size is bounded and malformed input returns an error. photocraft-io maps it to an RGB8 document with artboards, groups, shape layers, type layers, embedded smart objects, pixel layers and vector/layer masks; what can't be mapped is listed in the warnings. The embedded preview is now only a fallback when the native data can't be read, and only that preview is refused by Place and warningless imports. `cargo xtask corpus --affinity` pins 21 public CC0/MIT documents, sha256-verified; the io corpus test compares each import with the thumbnail Affinity saved in it (mean difference 0-4.6 of 255). Affinity export is not implemented: no Affinity installation was available to validate written files. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GQPh8UDgMyARR5Hat9UchC
1.9 KiB
Affinity documents
PhotoCraft opens native Affinity documents: .af files from Affinity 3 and .afdesign,
.afphoto and .afpub files from Affinity 1 and 2. Layers come in as editable PhotoCraft layers:
- pages and artboards become artboards (Publisher spreads sit side by side);
- layers and groups become groups;
- curves and shapes (rectangles, ellipses, polygons, stars and the other geometric shapes) become shape layers with their fill, gradient and stroke;
- artistic and frame text becomes type layers, drawn with the fonts installed on your computer;
- placed JPEG and PNG images become embedded smart objects, and pixel layers become pixel layers;
- vector and pixel masks, opacity, visibility, locks, names and blend modes are kept.
The document is 8-bit RGB at the Affinity document's resolution. What PhotoCraft can't reproduce is listed in a warning when the file opens, for example layer effects, adjustment layers and live filters, brush strokes (drawn as plain strokes), special shapes such as clouds and hearts (drawn as ellipses), master pages, and CMYK or Lab colour (converted to RGB without the document's profile). Nothing is dropped without a warning.
PhotoCraft can't write Affinity files. An opened Affinity document has no save path: Save asks for
a new file (.pcraft, PSD, PNG…) and never writes over the Affinity file.
If the native data can't be read (a damaged file, or a layout PhotoCraft doesn't know), PhotoCraft opens the small PNG preview Affinity stores in the file instead, as a single pixel layer named “Affinity preview”, and the warning says why. That preview can't be placed or used by File ▸ Place, stacks, batch processing or other imports that can't show the warning. Export PSD or PNG from Affinity in that case.
See the crate's notes for the full list of what is imported, how the reader was written and validated, and its safety limits.