godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.84k stars 20.98k forks source link

Importing a jpg image may result in wrong colors. #92017

Open catpieyum opened 4 months ago

catpieyum commented 4 months ago

Tested versions

4.2.2.stable, 4.2.1.stable, 3.5.2.stable

System information

Windows 10, Windows 11

Issue description

When importing this jpg: album the colors get messed up in the preview/editor and at runtime. image This happens to any image in the zips downloaded from this site: https://www.enchor.us The image can be found in the downloaded zip and is named album.jpg.

Steps to reproduce

Minimal reproduction project (MRP)

MRP.zip

Calinou commented 4 months ago
fire commented 4 months ago

A first guess is that is related to "adobe rgb" color space in the jpg. Will try to find out more.

fire commented 4 months ago
  1. If I open the jpg macos preview
  2. Export the jpg into png
  3. It loads into godot engine correctly.

editor_screenshot_2024-05-16T101842

catpieyum commented 4 months ago

When the .jpg image is imported into an image editor and exported as a .jpg again, it works correctly too. It's just that the issue shouldn't be happening in the first place.

fire commented 4 months ago

I think that Godot Engine is probably mis-interpreting BGR/RGB for the color channels, but needs investigation why.

Brezak commented 4 months ago

Wouldn't switching the channels keep the white text white instead of tinting if pink? Additionally this is how it looks when I swap the red and blue channels it looks like this album

fire commented 4 months ago

I don't think I should rush a pull request but a future task is to compare the results of https://github.com/richgel999/jpeg-compressor loading with https://github.com/libjpeg-turbo/libjpeg-turbo

Help welcome.

# Some differences on `exiftool album.jpg`.
Y Cb Cr Sub Sampling            : YCbCr4:4:4 (1 1)
# Compared to `exiftool 292a8bb83ccc4dda16234b1b9cb42f22.jpg` 
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)