element-hq / element-web

A glossy Matrix collaboration client for the web.
https://element.io
GNU Affero General Public License v3.0
11.76k stars 2.17k forks source link

Image previews created client-side sometimes have incorrect colors #11005

Open afontenot opened 5 years ago

afontenot commented 5 years ago

Description

See https://github.com/matrix-org/synapse/issues/6021 for some prior discussion.

In an encrypted chat, preview images have to be created by the client. When my browser uploads an image to an encrypted chat, the resulting image preview is incorrect (it appears desaturated).

My understanding of the problem: Currently preview creation is done by sticking the image data into a canvas, then snapshotting the data, before uploading it. This approach is broken on correctly color managed computers, because the data on the canvas will represent the output of the browser's color management process, not the image's original colors. You need to either create the preview image in Javascript without touching the DOM, or use some trickery to prevent the browser from applying color corrections to the canvas, if that's possible. (Since the canvas is off screen, this might turn out to be a browser bug, but that's not my area of expertise.)

Technically this bug is in matrix-react-sdk, but I was asked to file it here instead.

Steps to reproduce

Obviously, the preview image should accurately represent the full image, especially since for many images, it's unlikely anyone will ever click to view the full thing.

Logs being sent: yes

(Logs are almost certainly not relevant here, but I'll send them. It would be nice to have some reassurance from the GUI that the logs I'm sending aren't personally identifiable or contain other private information.)

Original image (created in GIMP, color bars are #ff0000, #00ff00, #0000ff) vs. image preview, downloaded from Riot.im:

rgbtest5 rgbtest5_preview

Version information

ara4n commented 3 months ago

some keywords: ICC color profile, colorimetry, colour profile