Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix: Don’t force a color transform by default for CYMK images #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 12, 2020

Conversation

rluba
Copy link
Contributor

@rluba rluba commented Feb 11, 2020

I ran into the same problem as #23, but instead of RGB images with a transformCode of 0, I experienced the color problems on CYMK images with such a transformCode.

The global default opts overwrote the color-mode dependent default of NOT transforming colors of CYMK images unless there’s a transformCode set.

The default of true rendered the ifs in line 841 and line 880 useless since this.colorTransform was always set and therefore always overwrote the color-mode dependent defaults in line 837 and line 876.

Unfortunately, I can’t provide an example jpeg with CYMK and transformCode = 0 since I’m not allowed to disclose any of the files I work with. 😕 But according to their metadata, they were authored with "Adobe Illustrator CS5.1" in 2015.

The default opts overwrote the sane default of NOT transforming CYMK images unless there’s a transformCode set.
The default of true rendered the `if`s in line 841 and 880 useless since `this.colorTransform` was always set.
@rluba
Copy link
Contributor Author

rluba commented Feb 11, 2020

Side note: the bug was introduced in #39.

@patrickhulce
Copy link
Collaborator

patrickhulce commented Feb 11, 2020

Oh great catch thanks @rluba! Mind adding a test case for this? I think I've created the correct cmyk JPEG to repro (jpeg + cmyk expectation are in fixtures.zip).

it('should be able to decode a CMYK jpeg with correct colors without transform', function (t) {
  var jpegData = fixture('tree-cmyk-notransform.jpg');
  var rawImageData = jpeg.decode(jpegData);
  t.equal(rawImageData.width, 400);
  t.equal(rawImageData.height, 250);
  var expected = fixture('tree-cmyk-notransform.cmyk');
  t.deepEqual(rawImageData.data, expected);
  t.end();
});

fixtures.zip

@rluba
Copy link
Contributor Author

rluba commented Feb 12, 2020

Thanks. Yes, your test image was broken before the fix and looks OK with this fix.

The colors are slightly off after opening and saving it with jpeg-js, but that’s probably a color profile issue. I’ve seen the same slight difference with my images.
comparison
(From left to right: original, before the fix, after the fix)

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

woohoo thanks @rluba great work!

@patrickhulce patrickhulce merged commit 4495701 into jpeg-js:master Feb 12, 2020
zed-0xff pushed a commit to zed-0xff/jpeg-js that referenced this pull request Feb 24, 2023
…s#64)

* Fix: Don’t force a color transform by default

The default opts overwrote the sane default of NOT transforming CMYK images unless there’s a transformCode set.
The default of true rendered the `if`s in line 841 and 880 useless since `this.colorTransform` was always set.

* Fix typo

* Add test with patrickhulce’s example image

BREAKING CHANGE: CMYK images will respect their embedded `transformCode`
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