saschanaz / jxl-winthumb

A JPEG XL (*.jxl) thumbnail handler for Windows File Explorer.
ISC License
375 stars 17 forks source link

Certain images have a very washed out appearance in both the thumbnail and viewing the actual image #42

Open keftie22 opened 4 months ago

keftie22 commented 4 months ago

I have been saving screenshots with mpv for years now and have been using a very high quality setting resulting in very large png files. I was trying to convert my entire collection to a much smaller, yet still lossless, file format and was going to give JXL a shot now again in 2024.

These are the settings I have been using to take screenshots in mpv often resulting in 10MB+ size png images:

screenshot-format=png
screenshot-high-bit-depth=yes
screenshot-png-compression=9
screenshot-directory='~/Pictures/mpv/'

Relevant section of mpv manual for reference

I installed this thumbnailer and after getting it working, I noticed that pretty much all of the thumbnails had this very washed out look to them. It basically looks like the original image has been destroyed. If I convert directly from the source png to the lossless jxl by basically any method I tried such as ffmpeg or XL converter, I get these washed out thumbnails. If I convert the source png to a png again, and then to JXL I actually get a normal looking image.

Example of what I'm seeing in the file explorer:

Screenshot 2024-07-13 150110

Then, upon opening them in the included image viewer I see the same washed out appearance as the thumbnail. However, opening them in another JXL capable image viewer such as ImageGlass, the image looks just fine as it was intended.

This is the same exact file just open in the 2 different programs:

image

It seems the images are actually fine but there is something about how this particular program is decoding them which is just destroying the contrast and colors. Even gimp is seeing these images as washed out but IrfanView seems to be seeing it correctly like ImageGlass does. I don't know why only certain programs are correctly decoding it.

Information about the video the screenshots were being pulled from:

Screenshot 2024-07-13 153412

MediaInfo text output of one of the source PNG files:

General
Complete name             : C:\Users\kft\Pictures\issue\3-1 source.png
Format                    : PNG
Format/Info               : Portable Network Graphic
File size                 : 9.84 MiB

Image
Format                    : PNG
Format/Info               : Portable Network Graphic
Compression               : Deflate
Width                     : 1 920 pixels
Height                    : 1 038 pixels
Color space               : RGBA
Bit depth                 : 16 bits
Compression mode          : Lossless
Stream size               : 9.84 MiB (100%)

MediaInfo doesn't seem to give anything useful on JXL files yet though but Gimp gives me this in the image properties:

image

keftie22 commented 4 months ago

Also here is one of the actual source png files themselves just for reference. You can convert it directly to JXL and potentially see the same issue. Github is not letting me upload the .jxl file itself because it says it doesn't support that file type.

3-1 source

saschanaz commented 3 months ago

I can reproduce this. At first I suspected maybe it was Photo Viewer that couldn't render 16bit pixels well, but it can render PNG well and I can also confirm that the converted JXL (generated by simple cjxl call without any options) renders well on ImageGlass. Reverting #37 did not help.

Unsure what could be the cause, but attaching JXL for future reference. 348500482-b548d3fa-c9df-4e67-bcfa-32935a0e3b80.zip

saschanaz commented 3 months ago

jxlinfo reports "709 transfer function" instead of "sRGB transfer function" which is something interesting.

box: type: "JXL " size: 12, contents size: 4
JPEG XL file format container (ISO/IEC 18181-2)
box: type: "ftyp" size: 20, contents size: 12
box: type: "jxll" size: 9, contents size: 1
box: type: "jxlc" size: 201976, contents size: 201968
JPEG XL image, 1920x1038, lossy, 16-bit RGB+Alpha
num_color_channels: 3
num_extra_channels: 1
extra channel 0:
  type: Alpha
  bits_per_sample: 16
  alpha_premultiplied: 0 (Non-premultiplied)
have_preview: 0
have_animation: 0
Intrinsic dimensions: 1920x1038
Orientation: 1 (Normal)
Color space: RGB, D65, sRGB primaries, 709 transfer function, rendering intent: Relative
saschanaz commented 3 months ago

The decode result of jxl-oxide-cli also looks broken, so I guess this is the library problem. I'll report there. (Edit: https://github.com/tirr-c/jxl-oxide/issues/318)

saschanaz commented 3 months ago

Actually, djxl gives the same washed out result. Huh?