stashapp / stash

An organizer for your porn, written in Go. Documentation: https://docs.stashapp.cc
https://stashapp.cc/
GNU Affero General Public License v3.0
8.48k stars 755 forks source link

[Feature] Is it possible to get JPEG XL images working? #4044

Open JadedMagician opened 11 months ago

JadedMagician commented 11 months ago

Discussed in https://github.com/stashapp/stash/discussions/3324

Originally posted by **DevonAA** December 31, 2022 It seems stash app does not recognize the JPEG XL image format. With "jxl" added as image extension the log shows: `error processing ".jxl": decoding image file ".jxl": image: unknown format` I've converted all my images from JPEG to JPEG XL a long time ago and saved 1 TB+ disc space with zero (lossless) quality loss. Will definitely not convert back to an older worse format. From what I understand the stash app uses FFMPEG. Good! A quick internet search tells me FFMPEG added JPEG XL support ca. 6 month ago - so that should be no problem - I've updated it a few days ago. Because I use FFMPEG for many things I just copy the exe it into C:\Windows. Not sure if stash uses that one or maybe it comes with it somehow packed into "stash-win.exe" !? Any idea how I can verify what FFMPEG version stash app is using? (To check for JPEG XL support) Online JPEG XL converter for tests: [https://jpegxl.io/](https://jpegxl.io/)

Apple is currently rolling out support for JPEG-XL across both macOS and iOS, including Safari, which makes up 20% of the browser market. In light of that, now would be a good time to consider adding jxl support to Stash. JPEG-XL can losslessly compress JPEG files by 20-50%, which would be incredibly useful for those of us that have large image collections.

DingDongSoLong4 commented 11 months ago

Currently, Stash can only use ffprobe to scan images which aren't inside zip files - could that be the issue? From that error message, it seems that stash is falling back on using Go's built-in image package, which does not support JPEG XL.

If you look in the logs do you see a "File could not be read with ffprobe" message? That means that stash tried to use ffprobe but it failed, so it fell back on the image package.

As for what ffmpeg binary stash uses, it first looks in your system PATH (which should include C:\Windows), and will only fallback to downloading its own version into your .stash directory (or wherever the config file is) if it can't find anything or if the found executable doesn't support a few features (the list is here). If you don't have an ffmpeg.exe or ffprobe.exe in your .stash directory, then stash should be using your version.

I just tested it myself and it seems to work, but jxl images are being detected as image clips instead of images (it seems that all formats besides png, jpeg, webp and avif are detected as image clips), which causes the frontend to display them incorrectly. This is the same issue as #3913, but for JPEG XL. Thumbnail generation also doesn't work.

This area probably needs a bit of a rework - to add support for more image formats, to make image clip detection more consistent and to have scanning work the same whether in a zip file or not.

DogmaDragon commented 2 weeks ago

There is a decoder for it https://github.com/gen2brain/jpegxl / https://pkg.go.dev/github.com/gen2brain/jpegxl in Go (uses purego).