Repository navigation
.ai import: CMYK images in the editing data keep their ink amounts - #2199
Merged
bflatastic merged 1 commit intoOct 15, 2026
Merged
Conversation
Messhias
approved these changes
Oct 15, 2026
Messhias
left a comment
Contributor
There was a problem hiding this comment.
.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
force-pushed
the
fix/ai-cmyk-images-keep-samples
branch
from
October 15, 2026 21:00
067aaba to
dc179c3
Compare
Member
|
Thanks @dotCooCoo. Rebased onto main and merged after the full local gate passed (fmt, clippy, tests, layers, wasm). |
Merged
4 tasks done
4 tasks done
3 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
By default a
.aifile, or an EPS with editing data, opens from its editing data. Onmainthe reader converts eachembedded 8-bit CMYK image to RGB and stores it as a PNG (
crates/eps/src/import/ai/read.rs, thecmyk_rgbcall inimage()), so the document loses the image's ink amounts. When the same.aiis opened witheditingData: false, thePDF 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 hidespart 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_amountsreads a 3 × 1 CMYK image with and without an alpha channel andchecks 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_partopens one
.aiwhose editing data and PDF part hold the same CMYK image, with and withouteditingData: false, andchecks that both give the same ink amounts.
import_fuzz's editing-data fixture gains a CMYK image with an alphachannel, and
the_editing_fixture_reads_its_cmyk_image_with_its_maskchecks that the unmutated fixture reads it. Eachtest 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 layersandcargo xtask assets. At 20,000 cases,mutated_encrypted_pdfs_never_panic,pasted_pdf_never_panicsandpdf_mutated_export_never_panicsfail with a panicin hayro-syntax's
object/dict.rs:104, onmainat b12a52f too.On Windows 11 (x86-64) with rustc 1.99.0, on top of
mainat b12a52f:CRAFT_FONTS_DIR=<craft-fonts checkout> cargo xtask cipasses its 8 steps: 6,591 tests passed, 0 failed, 9 ignored.git merge-treereports no conflicts withmainat b12a52f. It conflicts with #2140 on adjacent lines ofdocs/target-app-parity.md; keeping both sides resolves it.Checklist
cargo xtask cipasses (fmt, clippy, tests, assets, brands, layers, wasm).unwrap(),expect(),panic!,unreachable!,todo!orunimplemented!outside tests, and no unchecked indexing on data from files, parameters ormessages. Errors are returned as
Resultand shown to the user(why and how).
ASSETS.md.