libjxl / libjxl

JPEG XL image format reference implementation
BSD 3-Clause "New" or "Revised" License
2.58k stars 252 forks source link

Dart + Flutter bindings? #2681

Open markg85 opened 1 year ago

markg85 commented 1 year ago

Is your feature request related to a problem? Please describe. The "end goal" is to use JPEG XL images in flutter just like you can now use JPEG/PNG/....

Describe the solution you'd like Probably first a binding library from libjxl (C++) to Dart. And from there another library to integrate with Flutter.

Describe alternatives you've considered Google killed the alternatives. It was supposed to land in Chrome (it was there) but google killed it. And with that same reasoning they refuse to add it in Flutter.

Additional context Does such a library exist? Would it be viable to start a bounty project for this? I would pledge some $ for that for sure!

But i suppose the implicit question is also if libjxl is ready - in terms of features and performance - to run in places where flutter is run. That would be mainly on mobile (android/ios) apps but not exclusively! It should also work fine on the desktop platforms out there (win/mac/lin).

jonsneyers commented 1 year ago

If I understand correctly, flutter uses skia, so I guess if jxl support would be added to skia, that would also solve this.

Is there already an open issue / feature request to add jxl support to skia? If not, then it would be good to create one!

To answer your question on whether libjxl is ready in terms of features and performance: imo yes it is.

markg85 commented 1 year ago

That changed this year: https://www.youtube.com/watch?v=vd5NqS01rlA The impeller source is here.

Given that google still nuked JXL despite it receiving a lot of support and it being the no.1 (or 2?) most starred issue, i think it's safe to say that any jpeg xl support inside google-lead products isn't going to come from them.

In flutter there has been the request for it but it too has been hammered down with the m00t argument of additional code, maintaining, inferior codec, etc...

(yeah, kinda getting irritated by google's stance, it probably shows in this reply)

Quackdoc commented 1 year ago

typically you wouldn't add it right to flutter. you would use some sort of plug-in of sorts, however what I do for image support, is I actually use media_kit which is libmpv, this means most image formats that ffmpeg supports can be supported like that, it's not the super great solution because ffmpeg has size limitations. however for most uses it's perfectly fine.

I did actually do some work on enabling LibJXL in media_kit, I haven't yet tested it, but if it's something that you'd be interested in, it shouldn't be too much more work to get it going

EDIT: I should mention, this is only for Android. I didn't bother with iOS because flutter supports falling back to platform codecs, Windows wouldn't be hard to add, Linux uses the system ffmpeg so that should already be done.

https://github.com/Quackdoc/libmpv-android-video-build/pulls

mo271 commented 1 year ago

https://github.com/flutter/flutter/issues/113476 corresponding flutter issue

markg85 commented 1 year ago

@Quackdoc ... media_kit ...

Just looked at that project to see if using it would make sense. In my case the use of JXL is for image gallery purposes with lots of images being displayed at any given time.

That project is a full-fledged video player :) While that might work, it is - to put it mildly - overkill.

My line of thought was more along the lines of a package like this https://pub.dev/packages/flutter_avif (implements image components for AVIF), but then one for JXL. That would be perfect.

markg85 commented 1 year ago

Hmm, i might have changed my opinion here in a matter of minutes. Funny how things go sometimes ;) I still want JXL in flutter, that hasn't changed.

But... If every format needs to write their own dart bindings (and flutter component) then adoption of new formats sure is slow.

There are solutions for that although with the caveat that you still need to get support in those solutions before it's useful. Think of image manipulation/libraries/frameworks like imlib2, graphicsmagick, libgd and libvips (just to name a few).

Of those (there's many more), some are slow in development and adoption of new formats (like libgd), and some are fast (like libvips). Of those listed here libvips and imagemagick have JXL support.

I now think it makes more sense to go for one of those projects for dart bindings and a flutter plugin. In fact, ImageMagick might already be possible.

StefanOltmann commented 7 months ago

If I understand correctly, flutter uses skia, so I guess if jxl support would be added to skia, that would also solve this.

It will help Compose Multiplatform apps, which includes regular Android apps. 🙂