Skip to content
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

color looks wrong when CMYK jpg changed to RGB after opened and saved by image-rs #1440

Open
wellitecho opened this issue Feb 26, 2021 · 6 comments

Comments

@wellitecho
Copy link

wellitecho commented Feb 26, 2021

This happens when I simply used image-rs to open and save a CMYK jpg file

Expected

I expect the CMYK jpg file stays the same(file size, colorspace, etc.)
I did not expect a CMYK jpg be changed to RGB jpg automatically. Because this CMYK jpg is used for printing.

Actual behaviour

the original CMYK jpg file is 12.5Mb, in CMYK; after opened and saved by image-rs, the size was changed to 2.2Mb, color spaced was changed to RGB(found out with Photoshop), and the image color looks different than the original file.

Reproduction steps

Download the original CMYK image file from the link below, and simply run:

use image;
/*
Cargo.toml:
[dependencies]
image = "0.23"
*/
fn main() {
    let img = image::open("cmyk_original.jpg").unwrap();
    img.save("cmyk_open_and_saved.jpg").unwrap();
}

Provide source code, a repository link, or steps
original cmyk image file uploaded to mega.io

open and saved by image-rs

edit: added links to images

@wellitecho
Copy link
Author

closed; moved to jpeg-decoder module

@wellitecho
Copy link
Author

wellitecho commented May 5, 2021

Previously I moved this issue to image/jpeg-decoder(issue image-rs/jpeg-decoder#185), and there is no update after two months. Maybe the issue should be reopened here for people who's interested? Don't know what the right protocol is here.
Sorry if any inconvenience/trouble caused.

@wellitecho wellitecho reopened this May 5, 2021
@fintelia
Copy link
Contributor

fintelia commented May 5, 2021

From the discussion in the other thread there seems to be two issues at play:

  1. The image data is converted from CMYK to RGB. This is intended behavior for the image crate which always converts to a supported ColorType, but it may make sense for the jpeg-decoder crate to also support keeping the image in CMYK format.

  2. The embedded ICC profile isn't applied when doing the conversion. This is not the desired behavior, but fixing it will take a whole bunch of work which no one has yet expressed an interest in doing. See Color space information #786 and the linked issues for more discussion on color space handling.

@wellitecho
Copy link
Author

wellitecho commented May 5, 2021

Thanks for your prompt reply.
Indeed, it automatically converts CMYK to RGB as comment shown here in image/decoder.rs by image/decoder.rs fn cmyk_to_rgb. It's just that this RGB output image is not very usable for printing.
From the looks of it, it will take quite some time and effort to achieve the desired result.
Thanks for working on and improving this great crate. It works well in many cases.

@wellitecho
Copy link
Author

Hi, is there any update on this issue? Is CMYK support, or other color space related support added? Thanks.

@fintelia
Copy link
Contributor

Alas, we're still blocked on someone volunteering to design and implement the relevant changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants