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

Opening and saving an sRGB image yields different colors #2247

Open
rrohrer opened this issue May 29, 2024 · 5 comments
Open

Opening and saving an sRGB image yields different colors #2247

rrohrer opened this issue May 29, 2024 · 5 comments

Comments

@rrohrer
Copy link

rrohrer commented May 29, 2024

This happens in image 0.25.1

Expected

Colors should be preserved when an image is opened and saved.

Actual behaviour

Two different images with different colors (after image opened and saved, it’s much more yellow)

Reproduction steps

Take an sRGB IEC61966-2.1 encoded jpeg, open it with Reader, call the save method on the result, and compare the before and after images. Looking at meta data, it preserves the sRGB color profile, but the result is different colors.

Provide source code, a repository link, or steps:

use image::{io::Reader as ImageReader, ImageError};

fn main() -> Result<(), ImageError> {
    let image = ImageReader::open("input.jpg")?.decode()?;
    image.save("output.jpg")?;

    Ok(())
}
@fintelia
Copy link
Contributor

fintelia commented Jun 2, 2024

Could you share a failing image? Is it possible there's an embedded ICC profile and we have a longstanding issue to handle those better

@rrohrer
Copy link
Author

rrohrer commented Jun 4, 2024

I was using the full resolution download of this flickr image: https://flickr.com/photos/alexislours/53637525879/

I believe it does have an embedded ICC profile

@rrohrer
Copy link
Author

rrohrer commented Jun 4, 2024

Reading through the linked issue, and the other issues around it… is there currently a work around or are embedded ICC profiles a no-go for now with image-rs?

@fintelia
Copy link
Contributor

fintelia commented Jun 5, 2024

We have the low level capability to read ICC profiles, but aren't yet able to write them when encoding images

@rrohrer
Copy link
Author

rrohrer commented Jun 5, 2024

Ah, so the correct thing would be to read the profile, apply it, then save in a format image-rs supports. Thanks!

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

No branches or pull requests

2 participants