Bug 426720 - broken colors (gamma?) when saving images
Summary: broken colors (gamma?) when saving images
Status: ASSIGNED
Alias: None
Product: gwenview
Classification: Applications
Component: general (other bugs)
Version First Reported In: Other (add details in bug description)
Platform: Other Linux
: VHI normal
Target Milestone: ---
Assignee: Gwenview Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-19 11:21 UTC by Martin Sandsmark
Modified: 2022-02-21 09:05 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
broken image file (2.33 MB, image/png)
2020-09-19 11:21 UTC, Martin Sandsmark
Details
original file (2.32 MB, image/png)
2020-09-19 11:22 UTC, Martin Sandsmark
Details
Example: Wallpaper of Plasma 5.3 (original file) (1.96 MB, image/png)
2022-02-21 09:03 UTC, Jan Rathmann
Details
Example: Wallpaper of Plasma 5.3 (saved by Gimp) (2.09 MB, image/png)
2022-02-21 09:04 UTC, Jan Rathmann
Details
Screenshot of Plasma 5.3. wallpaper opened in Gwenview (455.52 KB, image/png)
2022-02-21 09:05 UTC, Jan Rathmann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Sandsmark 2020-09-19 11:21:43 UTC
Created attachment 131771 [details]
broken image file

When saving a png (created by imagemagick/`import`), the colors get broken.

None of the options for changing how Gwenview handles colors in Settings -> Advanced fixes it, but putting in a return in RasterImageViewPrivate::updateDisplayTransform() before anything is done fixes it.

I've attached both the original png and the broken one from Gwenview.

Happens with git master, and also before the last changes to color stuff I could find (b76047f541340df561c2d7b91b825814923843b5).
Comment 1 Martin Sandsmark 2020-09-19 11:22:01 UTC
Created attachment 131772 [details]
original file
Comment 2 Martin Sandsmark 2020-09-19 11:28:47 UTC
Seems like there's some funky business with gwenview's own color space handling + QColorSpace. Resetting the colorspace before (`image.setColorSpace(QColorSpace())`) saving in DocumentLoadedImpl::saveInternal() unbreaks it.
Comment 3 Nate Graham 2020-09-23 18:25:02 UTC
Yikes.

Feel free to send a merge request!
Comment 4 Martin Sandsmark 2020-09-28 09:22:22 UTC
Just not sure if always clearing the color space is the right way to go... Testing with e. g. chrome also shows the gamma completely wrong, so it might be an issue in imagemagick (recent regression, I haven't seen it before).

But maybe we could add a new checkbox with "ignore color profiles" together with the "Apply color profile embedded in the image file" setting?
Comment 5 Nate Graham 2020-09-28 21:24:21 UTC
In general I think it's better to fix the issue rather than adding an option to work around it, but I admit to knowing next to nothing about color profiles, so I don't know if such an option would be broadly useful outside the scope of allowing the user to work around this bug.

Regardless, I think we should try to fix the bug itself, is possible.
Comment 6 Bug Janitor Service 2020-10-27 12:23:28 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/gwenview/-/merge_requests/20
Comment 7 Jan Rathmann 2022-02-21 09:03:44 UTC
Created attachment 146989 [details]
Example: Wallpaper of Plasma 5.3 (original file)

I'm not completely sure but I'm seeing a bug that might by the same as this one.

There is a rare number of images that have weird/broken colors (desaturated/"much too bright") when viewing them with Gwenview.

One example is the wallpaper of Plasma 5.3 which I'm attaching here.

Some testing revealed that:

* it's the same both on Wayland and X11
* Colors get displayed correctly in Gimp, Dolphin preview and when I set the image as my wallpaper
* If I save an affected image in Gwenview, the colors look broken also in all other apps.
* If I save the image in Gimp, the copy gets displayed correctly even in Gwenview (I'm attaching this one too.)
* I couldn't spot any suspicious difference in the metadata of affected/unaffected images.

Kind regards, Jan
Comment 8 Jan Rathmann 2022-02-21 09:04:30 UTC
Created attachment 146990 [details]
Example: Wallpaper of Plasma 5.3 (saved by Gimp)
Comment 9 Jan Rathmann 2022-02-21 09:05:18 UTC
Created attachment 146991 [details]
Screenshot of Plasma 5.3. wallpaper opened in Gwenview