Skip to content

.ai import: 1-bit RGB and CMYK images in the editing data open in their colors - #2293

Merged
bflatastic merged 1 commit into
storytold:mainfrom
dotCooCoo:fix/ai-one-bit-color-images
Oct 15, 2026
Merged

bflatastic merged 1 commit into
storytold:mainfrom
dotCooCoo:fix/ai-one-bit-color-images

Conversation

@dotCooCoo

Copy link
Copy Markdown
Contributor

What and why

On main the editing data reader sizes each row of a 1-bit image as width × channels bits, padded to a whole byte
(crates/eps/src/import/ai/read.rs:1659), but reads one bit per pixel and makes the pixel gray from it
(:1672-1675). A 1-bit RGB or CMYK image comes out as a black and white image of the wrong bits: a 3 × 1 RGB image of
red, green and blue reads as white, black and black. When the layers then differ from the page by more than 5%, the
file opens from its PDF part instead, with the warning "the file's layers weren't read from its editing data (the art
on them differs from the page's in 36.8% of it): they come from its PDF part".

The reader now takes channel c of pixel x from bit x × channels + c of the row, most significant bit first, as the
PostScript interpreter reads a colorimage (crates/eps/src/import/data.rs:868 and :904). A set bit is the channel
at full strength, and the samples go through the same conversion as 8-bit ones. 1-bit gray images read as before.

How it was tested

import::ai::tests::one_bit_images_read_each_channel reads a 3 × 2 RGB image with padded rows, a 2 × 1 CMYK image and
a 3 × 1 gray image, and checks every pixel.
tests_aiimport::a_one_bit_rgb_image_opens_from_the_editing_data_in_its_colors opens a .ai whose editing data and
PDF part hold the same 1-bit RGB image with document.open, and checks that the layers come from the editing data and
that the pixels are red, green and blue. import_fuzz's editing-data tokens gain a 1-bit CMYK image with an alpha
channel. With the old bit index restored in the reader, both tests fail: the first at its first row, the second with
the warning above.

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), cargo xtask brands, cargo xtask layers and cargo xtask assets.

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,590 tests passed, 0 failed, 9 ignored.

git merge-tree reports no conflicts with main at 52b0728, which includes #2199.

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.

…ir colors

The editing data reader sized each row of a 1-bit image as width ×
channels bits, padded to a whole byte, but read one bit per pixel and
made the pixel gray from it. A 1-bit RGB or CMYK image came out as a
black and white image of the wrong bits. When that made the layers
differ from the page by more than 5%, the file opened from its PDF
part instead, with a warning.

The reader now takes channel c of pixel x from bit x × channels + c of
the row, a set bit being the channel at full strength, and converts
the samples as it converts 8-bit ones. 1-bit gray images read as
before.
@bflatastic
bflatastic force-pushed the fix/ai-one-bit-color-images branch from 1b62181 to 28cb75c Compare October 15, 2026 23:33
@bflatastic
bflatastic merged commit e41f781 into storytold:main Oct 15, 2026
1 check passed
@bflatastic

Copy link
Copy Markdown
Member

Thanks @dotCooCoo! Rebased onto main and landed with the batch after the full local gate.

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.

2 participants