mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-07 19:12:46 +00:00
The editing copy of a PDF-compatible .ai wrote every image as its outline filled with its average color. Embedded images are now written with their pixels, and linked images as placed files with a preview: - Embedded images are rasters in the form of the version 7 specification (section 8, https://13thmonkey.org/documentation/fonts/AI7FileFormat.pdf): %AI5_BeginRaster, the color space, the image matrix and the XI operands of current files, then the samples in binary in a %%BeginData section. Gray, RGB and CMYK images keep their samples (CMYK images their ink amounts), and see-through images their alpha channel after the color samples. The matrix is written to ten decimals. - Linked images are placed files (section 16): the matrix, the box of the file's pixels and its path, %%IncludeFile, the folder relative to the document's (when the relative path ends in the path's file name), and a preview of at most 256 pixels a side. - Images that can't be decoded or have more than 33,554,432 pixels (the most the reader reads) are written as their outlines filled mid gray, images of 16 bits a channel (CMYK TIFFs included) at 8 bits, and linked images in opacity masks and pattern tiles as embedded images, each with a warning. Each of these is written in the form VectorCraft's .ai reader reads, and the tests read the written data back through that reader. The reader now gives an image its name and opacity mask when the operators that end its raster (XH, Xr and the N after %AI5_EndRaster) come before its dictionary, reads an empty relative folder as the document's own folder, and looks for the %%EndData that ends an image's samples after the alpha channel its XI operands give it, preferring one whose next line is XH, so samples that hold the marker's bytes are read whole. Tests: the round trip of every kind of image and its state, a second write of what is read back giving the same bytes, the raster and placed-file forms, previews of large linked images, and the engine's editing copy with every save option; a fuzz case for damaged images and placed files. Docs: docs/file-format-parity.md.