Tauon icon indicating copy to clipboard operation
Tauon copied to clipboard

[Feature request] Support JPEG XL (.JXL)

Open C0rn3j opened this issue 2 years ago • 12 comments

image

Opening a folder like so with cover.jxl in it makes the cover picture not load:

tauon Rachel\ Mcalpine\ -\ Please\ Just\ Go

Some info about the format - https://jpegxl.info/

Even with lossless compression, JPEG -> JXL nets 10-20% space savings, which sure is nice for high-res covers

image

C0rn3j avatar Apr 25 '22 13:04 C0rn3j

I've committed a change to make Tauon look for jxl files now. But they will still fail to load due to missing support for JXL in Pillow https://github.com/python-pillow/Pillow/issues/4247

It seems you can install jxlpy pip3 install jxlpy --user which will provide a plugin for it. (I assume you're not using Flatpak). If you try that (after upgrading to future Tauon release or pull master) let me know if it works.

As this is a temporary workaround, I'm not going to be bothered adding this package to the AUR. But if anyone asks I could maybe add it to the Flatpak.

Taiko2k avatar Apr 26 '22 00:04 Taiko2k

I pulled up to date t_main.py, installed jxlpy via pip but I get an error now:

% rm -rf ~/.cache/TauonMusicBox && tauon Rachel\ Mcalpine\ -\ Please\ Just\ Go
Tauon Music Box v7.2.0
Copyright 2015-2022 Taiko2k [email protected]

Window size: [1598, 1015]
GTK theme is: breeze
Running from installed location
User files location: /home/c0rn3j/.local/share/TauonMusicBox
Found XDG-Downloads: /home/c0rn3j/Downloads
Found XDG-Music: /home/c0rn3j/Music
Install directory: /opt/tauon-music-box
Database loaded in 0.014 seconds.
Pychromecast not found
Start controller server
Start PHAzOR backend...
OPEN URI
Using SDL version: 2.0.20
Could not connect to gnome media keys
Applying theme: Vape
ERROR: Image load failed on track: 
- Rachel Mcalpine - Please Just Go/Rachel Mcalpine - Please Just Go - 01 Please Just Go.ogg
Auto save playtime
cannot identify image file <_io.BufferedReader name='Rachel Mcalpine - Please Just Go/cover.jxl'>
Thumbnail error
Rachel Mcalpine - Please Just Go/Rachel Mcalpine - Please Just Go - 01 Please Just Go.ogg
pa: Connect pulse
Writing database to disk... done

C0rn3j avatar Apr 26 '22 08:04 C0rn3j

Seems like it should be working on Tauons end, but the plugin isn't working? Not sure what to try next.

Taiko2k avatar Apr 26 '22 11:04 Taiko2k

image

Using the plugin's included example, it seems to be able to decode fine

C0rn3j avatar Apr 26 '22 12:04 C0rn3j

Yeah, that's the library itself. Maybe i need to do something to load the plugin into pillow

Taiko2k avatar Apr 26 '22 12:04 Taiko2k

This pillow example also worked, maybe Tauon needs to do the same JXLImagePlugin import, but that's just my uneducated guess.

from PIL import Image
from jxlpy import JXLImagePlugin

im = Image.open('cover.jxl')
im = im.resize((im.width*2, im.height*2))
im.save('cover_2x.jxl', lossless=True, effort=7)

C0rn3j avatar Apr 26 '22 12:04 C0rn3j

Yep that seems to have been the issue. Ive pushed another commit and it seems to be working now.

Taiko2k avatar Apr 27 '22 09:04 Taiko2k

Downloaded up to date t_main and t_draw.

While it does work now, startup times went from near instant to 15s+, and for those entire 15+ seconds tauon is having 100% usage of one thread.

Uninstalling jxlpy makes the startup times go back to normal. Not sure what is happening here.

C0rn3j avatar Apr 27 '22 10:04 C0rn3j

Odd, startup times are fine for me.

Taiko2k avatar Apr 27 '22 10:04 Taiko2k

jxlpy's fault apparently, Tauon is doing things right, will post a write up in a minute

C0rn3j avatar Apr 27 '22 10:04 C0rn3j

Turns out it's because of that enlarged cover_2x.jxl I have had from previous testing.

jxlpy absolutely chugs on it, especially since it's single threaded(https://github.com/olokelo/jxlpy/issues/9). And so does nomacs(which uses a different plugin) trying to open the picture, it takes 1900ms just to decode and that's using multiple threads.

image

Would it perhaps make sense for album covers to be "pop-in" on a different thread so it doesn't freeze the entire app while it's trying to load album art?

Here's the regular cover and the chug-chug enlarged version if you want to test it: cover.zip

I've packaged the library, would you please add it as an optdepends to your tauon package?

https://aur.archlinux.org/packages/python-jxlpy


Side note, there's a typo in one of the errors - Error loading directroy

C0rn3j avatar Apr 27 '22 11:04 C0rn3j

would you please add it as an optdepends to your tauon package?

Okay will do on next release.

Would it perhaps make sense for album covers to be "pop-in" on a different thread so it doesn't freeze the entire app while it's trying to load album art?

I made it block the main thread specifically because I didn't want it to pop-in. I could move it to another thread with a blocking timeout, but its a little of an annoying optimisation to have to make. I'd rather just hope most album art isn't 6000x6000.

Taiko2k avatar Apr 27 '22 11:04 Taiko2k

I suppose there's not much to do as JPEGXL has been working nicely, other than perhaps enabling multithread decoding to speed up loading times?

I also have some good news, your issue can be easily resolved by providing num_threads parameter to JXLPyDecoder.

https://github.com/olokelo/jxlpy/issues/9#issuecomment-1113984085

C0rn3j avatar Nov 29 '22 08:11 C0rn3j