Repository navigation
.ai import: 1-bit RGB and CMYK images in the editing data open in their colors - #2293
Merged
Merged
Conversation
…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
force-pushed
the
fix/ai-one-bit-color-images
branch
from
October 15, 2026 23:33
1b62181 to
28cb75c
Compare
Member
|
Thanks @dotCooCoo! Rebased onto main and landed with the batch after the full local gate. |
This was referenced Oct 16, 2026
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
On
mainthe 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 ofred, 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:868and:904). A set bit is the channelat 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_channelreads a 3 × 2 RGB image with padded rows, a 2 × 1 CMYK image anda 3 × 1 gray image, and checks every pixel.
tests_aiimport::a_one_bit_rgb_image_opens_from_the_editing_data_in_its_colorsopens a.aiwhose editing data andPDF part hold the same 1-bit RGB image with
document.open, and checks that the layers come from the editing data andthat the pixels are red, green and blue.
import_fuzz's editing-data tokens gain a 1-bit CMYK image with an alphachannel. 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 layersandcargo xtask assets.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,590 tests passed, 0 failed, 9 ignored.git merge-treereports no conflicts withmainat 52b0728, which includes #2199.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.