Skip to content

.ai import: CMYK images in the editing data keep their ink amounts - #2199

Merged
bflatastic merged 1 commit into
storytold:mainfrom
dotCooCoo:fix/ai-cmyk-images-keep-samples
Oct 15, 2026
Merged

bflatastic merged 1 commit into
storytold:mainfrom
dotCooCoo:fix/ai-cmyk-images-keep-samples

Conversation

@dotCooCoo

Copy link
Copy Markdown
Contributor

What and why

By default a .ai file, or an EPS with editing data, opens from its editing data. On main the reader converts each
embedded 8-bit CMYK image to RGB and stores it as a PNG (crates/eps/src/import/ai/read.rs, the cmyk_rgb call in
image()), so the document loses the image's ink amounts. When the same .ai is opened with editingData: false, the
PDF importer reads its PDF part and keeps the inks in a CMYK TIFF (crates/pdf/src/import_image.rs:90).

The reader now stores those samples with ImageBlob::cmyk_tiff, as the PDF importer does. An alpha channel that hides
part of the image becomes the image's opacity mask, a grayscale image over it, as in PDF import. An alpha channel that
hides nothing adds no mask. Grayscale, RGB and 1-bit images still open as RGBA PNGs.

How it was tested

import::ai::tests::cmyk_images_keep_their_ink_amounts reads a 3 × 1 CMYK image with and without an alpha channel and
checks that the ink amounts are byte-equal to the samples and that the alpha channel is a clipping opacity mask over the
image with the same values. tests_aiimport::a_cmyk_image_keeps_its_inks_from_the_editing_data_as_from_the_pdf_part
opens one .ai whose editing data and PDF part hold the same CMYK image, with and without editingData: false, and
checks that both give the same ink amounts. import_fuzz's editing-data fixture gains a CMYK image with an alpha
channel, and the_editing_fixture_reads_its_cmyk_image_with_its_mask checks that the unmutated fixture reads it. Each
test fails with the reader's CMYK branch turned off, and the first also fails without the mask.

Targeted checks: cargo clippy -p vectorcraft-eps --all-targets -- -D warnings,
cargo clippy -p vectorcraft-engine --all-targets -- -D warnings, cargo fmt --all -- --check,
cargo test -p vectorcraft-eps --lib import::ai (56 passed), cargo test -p vectorcraft-engine --lib tests_aiimport
(14 passed), PROPTEST_CASES=20000 cargo test --release -p vectorcraft-engine --test import_fuzz (111 passed),
cargo xtask brands, cargo xtask layers and cargo xtask assets. At 20,000 cases,
mutated_encrypted_pdfs_never_panic, pasted_pdf_never_panics and pdf_mutated_export_never_panics fail with a panic
in hayro-syntax's object/dict.rs:104, on main at b12a52f too.

On Windows 11 (x86-64) with rustc 1.99.0, on top of main at b12a52f:

  • CRAFT_FONTS_DIR=<craft-fonts checkout> cargo xtask ci passes its 8 steps: 6,591 tests passed, 0 failed, 9 ignored.

git merge-tree reports no conflicts with main at b12a52f. It conflicts with #2140 on adjacent lines of
docs/target-app-parity.md; keeping both sides resolves it.

Checklist

  • cargo xtask ci passes (fmt, clippy, tests, assets, brands, layers, wasm).
  • No panics in shipped code: no unwrap(), expect(), panic!, unreachable!, todo! or
    unimplemented! outside tests, and no unchecked indexing on data from files, parameters or
    messages. Errors are returned as Result and shown to the user
    (why and how).
  • Clean-room: nothing copied from Adobe products or GPL/AGPL code (AGENTS.md).
  • Every new asset has a row in ASSETS.md.

@Messhias Messhias left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.ai import: CMYK images in the editing data keep their ink amounts. Checklist cargo xtask ci is ticked.

When a .ai file, or an EPS with editing data, opened from its editing
data, the reader converted each embedded 8-bit CMYK image to RGB and
stored it as a PNG, so the document lost the image's ink amounts. When
the same .ai opens from its PDF part, the PDF importer keeps them in a
CMYK TIFF.

The reader now stores those samples with ImageBlob::cmyk_tiff, as the
PDF importer does (crates/pdf/src/import_image.rs). An alpha channel
that hides part of the image becomes the image's opacity mask, a
grayscale image over it, as in PDF import. Grayscale, RGB and 1-bit
images still open as RGBA PNGs.

Docs: docs/file-format-parity.md, docs/target-app-parity.md.
@bflatastic
bflatastic force-pushed the fix/ai-cmyk-images-keep-samples branch from 067aaba to dc179c3 Compare October 15, 2026 21:00
@bflatastic
bflatastic merged commit 0b10aa6 into storytold:main Oct 15, 2026
1 check passed
@bflatastic

Copy link
Copy Markdown
Member

Thanks @dotCooCoo. Rebased onto main and merged after the full local gate passed (fmt, clippy, tests, layers, wasm).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants