waycrate / wayshot

Mirrored at https://git.sr.ht/~shinyzenith/wayshot | screenshot tool for wlroots based compositors implementing zwlr_screencopy_v1
https://crates.io/crates/wayshot
BSD 2-Clause "Simplified" License
107 stars 18 forks source link

Support JPEG XL #11

Open roland-5 opened 2 years ago

roland-5 commented 2 years ago

If I understand correctly, wayshot by default save files as png and we can save as jpg extension too. I don't know if this is possible or would be enchantment you wanted in your project, but saving screenshots as JPEG XL (jxl) files would be awesome.

Very nice project!

Shinyzenith commented 2 years ago

Yep this is possible and I'm willing to work on it once I gain enough knowledge about encoding with jxl.

Shinyzenith commented 1 year ago

https://github.com/image-rs/image/issues/1765 https://github.com/image-rs/image/issues/1765

Related issues. I do not want to do any custom encoding / decoding right now to keep the codebase simple and easy to understand. If it does get implemented in image-rs then I'd be more than happy to expose libwayshot API calls for JXL.

murlakatamenka commented 4 months ago

Yeah, JPEG XL is the real deal, especially with the recent 0.10 speedups of reference libjxl implementation, see here:

https://cloudinary.com/blog/jpeg-xl-and-the-pareto-front


My quick tests show that using is really-really fast (Hyprland, wayshot compiled with -march=native, Ryzen 5600):

image


zune-image supports jpeg xl, but that's another story, right?

Shinyzenith commented 4 months ago

That doesn't seem very fast from the numbers shown -- again I might be mistaken in my interpretation. I'm generally against adding new crates to the dependency graph unless unavoidable. Does zune support interop with image crate types?

murlakatamenka commented 4 months ago

There are a few zune- crates behind feature flags for image-rs, so there is at least some reference of interop between those.

While jxl is cool, it shines brighter when encoding complex stuff like real world photos in high resolution, like shown in the article. And in lossy but visually lossless scenarios.


If we implement png optimization, then jxl gets less attractive for desktop screenshot case. Still an image format to look at, because it's like jpeg, but better in everything, and with lossless mode. Just needs more time and adoption (hello, Google Chrome).