Skip to content

Support reading CMYK, YCCK JPEGs #1246

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
Sep 13, 2018
Merged

Conversation

zbjornson
Copy link
Collaborator

libjpeg automatically converts YCCK to CMYK, so we get that for free by adding CMYK support. Also adds a test for grayscale and does some cleanup.

  • Have you updated CHANGELOG.md?

Fixes #425

src/Image.cc Outdated
if (_data) {
delete[] _data;
_data = nullptr;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice 🙌

btw. I think it's safe to run delete on a nullptr, so I don't think you need the if? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, it's defined behavior. Removed the guard.

img2.onerror = function () {
done(new Error('Failed to load image'))
}
img2.onerror = done
Copy link
Collaborator

Choose a reason for hiding this comment

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

Neat!

Copy link
Collaborator

@LinusU LinusU left a comment

Choose a reason for hiding this comment

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

Great 👏

Copy link
Collaborator

@LinusU LinusU left a comment

Choose a reason for hiding this comment

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

👏 🥇

@zbjornson zbjornson merged commit a3b090e into Automattic:master Sep 13, 2018
@zbjornson zbjornson deleted the zb/cmykjpg branch September 13, 2018 07:25
@marcj
Copy link

marcj commented Oct 7, 2018

Is there a way to fix color space (or whatever gives too much colors)? I tried this PR and got following:

Correct: Browser (newest Chrome)

screen shot 2018-10-07 at 13 27 38

Wrong: Node-Canvas:

screen shot 2018-10-07 at 13 27 49

Actual image (25MB): https://drive.google.com/open?id=1LttH_DNl_Y5Dap__hQ88MhHqqb2YgJfe

As you can see, the colors of the right image is a bit too colorfull. Any idea how I can debug?

@zbjornson
Copy link
Collaborator Author

@marcj the EXIF data for that JPEG says it doesn't have an embedded color space, so I think that can be ruled out. Hard to say what layer that difference comes from... depending on how you got the images you embedded in your post (were they screenshots?) it could even be Chrome's display rendering vs. the MacOS Preview app or something.

@marcj
Copy link

marcj commented Oct 7, 2018

Its both a screenshot. The (wrong) image from node-canvas looks across multiple viewer the same, so I assume node-canvas does not read the CMYK file correctly.

I use now sharp (https://github.com/lovell/sharp) to convert the CMYK image to RGB first before using it in node-canvas, which looks very good. However, I'd not like to do that as it's rather slow.

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