d2phap / ImageGlass

🏞 A lightweight, versatile image viewer
https://imageglass.org
Other
7.34k stars 482 forks source link

Add JPEG XL Support #940

Closed dotjaz closed 3 years ago

dotjaz commented 3 years ago

System info:

Expected behavior:

JPEG XL not supported

Actual behavior:

JPEG XL not supported

Please add JPEG XL support

Sample files:

JXL.zip

d2phap commented 3 years ago

Hi @dotjaz

dotjaz commented 3 years ago

Hi @d2phap

Happy holidays :)

  • What is the extension of JPEG XL? Is it also .jpeg?

The extension is .jxl

I believe it's listed as RW (Requires the brunsli delegate library) here.

  • Do you have samples of JPEG XL files?

There aren't many publicly available ones, so I've made 2, from Wikimedia pictures using cjxl. There are 2 modes of compression included, lossless JPEG transcoding (losslessly reversible JPEG <-> JXL) and lossy (PNG -> JXL)

http://s000.tinyupload.com/?file_id=63495492614477479053

d2phap commented 3 years ago

Hi @dotjaz

image

dotjaz commented 3 years ago

Hi @d2phap

What do you mean install brunsli? That compiles to Linux binaries.

ScriptTiger commented 3 years ago

Here are the brunsli binaries for Windows: https://nightly.link/google/brunsli/workflows/ci/master/windows

ScriptTiger commented 3 years ago

@dotjaz, as quoted from the official JPEG XL reference implementation that you linked:

WARNING: until further notice, do not depend on future decoders being able to decode the output of a current encoder.

So trying to use the brunsli project to decode images you encoded with cjxl is obviously not guaranteed to work since even week-old versions of djxl that comes with cjxl are not guaranteed to do that since it's not even finished being implemented yet.

In your own words:

There aren't many publicly available ones, so I've made 2

It's because nobody would be guaranteed to be able to view any of them. Any JXL on the web more than a week old may never be able to be decoded ever again by any of the current or future decoders. That's also the whole reason why ImageMagick requires delegate entries to an external encoder/decoder, because it wouldn't make sense for it to include it with the project yet before the spec has even been finished.

I would say just wait for the working group to finish or, if you have cjxl/djxl working, make your own delegate, which is a configuration file that tells Magick.Net how to encode/decode specific formats. As long as you use an encoder and decoder that came together, it should work. Otherwise trying to get ImageGlass to officially support JXL in general is a bit silly when the codecs currently available can't even be guaranteed to decode their own images from week to week. I'm sure it will be supported as soon as they can agree on an implementation that will be guaranteed to always work, AKA a standard. But @d2phap is just developing an image viewer. There is a reason why it takes the Joint Photographic Experts Group, Google, and Cloudinary all putting their heads together to figure the codec out, and that's a whole different ball game than just this viewer.

A similar issue also popped up for GIMP (https://gitlab.gnome.org/GNOME/gimp/-/issues/4681) and one of the devs replied:

Use is currently discouraged until the file format specification is finished.

Things like waiting for the spec to be finished before writing code for it should be obvious, but there are plenty of people out there that feel like they just can't wait. And this is not a shot at you specifically, @dotjaz, but people just need to be patient.

ScriptTiger commented 3 years ago

I don't know about delegates with Magick.NET, but if you get ImageMagick you can just edit the delegates.xml. It's super straightforward when you read it and you can just add your own delegate lines to the delegatemap depending on what formats you're converting to and from. After you tell ImageMagick how to decode an image, you can then view it using magick image.jxl win:, which basically decodes the image to MIFF, the internal image format of ImageMagick, and then pipes it to IMDisplay.exe. So if you're just playing with JXL for your own testing purposes, this should get you what you want.

d2phap commented 3 years ago

Thanks @ScriptTiger for the details. I will keep this open and look back when it's settled out

Wolfrisger commented 3 years ago

just an info. https://squoosh.app now support JPEG XL.

d2phap commented 3 years ago

I updated Magick.NET lib in the latest build of IG Moon (https://imageglass.org/moon), JPEG XL is supported. Sample file: jpegxl-logo.zip

image

But when I test with your attached files, it shows error. I guess the file conversion is not correct 🤔

image

Diamondragon commented 3 years ago

Not sure if this has been cleared up, but brunsli has been totally taken out of the JPEG XL spec. JPEG transcode is now done by encoding JPEG block coeffs directly as VarDCT 8x8 blocks.

I have a bug in the latest release of ImageGlass Moon related to recompressed JPEG files. Specifically, they don't seem to display. I get the same error in your screenshot just above. I've attached a sample below.

xeno_hikari.zip

Not sure why it wouldn't work in ImageGlass, but I know losslessly recompressed JPEGs weren't working in squoosh.app, and they seem to have fixed it by changing the signature. Basically, it wasn't recognising valid JXL files as JXLs.

https://github.com/GoogleChromeLabs/squoosh/pull/969

[/^\x00\x00\x00\x0cJXL \x0d\x0a\x87\x0a/, 'image/jpegxl']

cocoon commented 3 years ago

Hi, just for your information, JPEG-XL support was already added Jan 9 2021: https://github.com/d2phap/ImageGlass/pull/962

For a working version you can follow my small guide that uses a commit where all is working still for jxl: https://github.com/cocoon/jxl.Net/wiki/Image-Viewer-with-JPEG-XL-Support#imageglass

There is a bug in later ImageMagick versions that's why it fails to displayx jxl.

I have opened a case already here: https://github.com/ImageMagick/ImageMagick/issues/3375#issue-824499594

d2phap commented 3 years ago

Thanks @cocoon !

cocoon commented 3 years ago

The issue is now fixed in Magick.Native.2021.3.21.236

I compiled Magick.NET on my own and tested it and now I could open all my previously "unreadable" jxl files without a problem. So looks good and as soon as a new Magick.NET version is released it should be good.

d2phap commented 3 years ago

Updated ImageGlass Moon, https://imageglass.org/moon

image