Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebP Support #121

Closed
KuroThing opened this issue Mar 4, 2017 · 68 comments · Fixed by #1552
Closed

WebP Support #121

KuroThing opened this issue Mar 4, 2017 · 68 comments · Fixed by #1552

Comments

@KuroThing
Copy link

There appears to be no clear statement, regarding if WebP Encoding / Decoding will be added at any point in time. The only references to "WebP" i could find, was #11 (comment), which i don't know if it holds any value.

WebP support isn't listed in anywhere meaningful like #10 (Codecs) or an unchecked item in Features like Tiff support is.

@JimBobSquarePants
Copy link
Member

Hi @KuroThing

That will be because there is no WebP on the current roadmap. We're trying to replicate and improve on the functionality offered by System.Drawing for now. Once we have that, maybe.... maybe we might have a go at adding WebP.

@Jogai
Copy link

Jogai commented May 15, 2018

Expect more questions like this because google's lighthouse tool recomments webp or jpeg 2000/xr: https://developers.google.com/web/tools/lighthouse/audits/webp

@JimBobSquarePants
Copy link
Member

They can recommend all they like, the browser support for those formats is terrible!

@ChrisBellew
Copy link

Any chance you could offer some comments on what's stopping this from moving forward, besides finding time to generously donate of course...perhaps someone from the community could have a go at adding support?

Are there license problems?
Is it going to be reaaaally hard?

Thanks :)

@JimBobSquarePants
Copy link
Member

Is it going to be reaaaally hard?

😆

That's the one. I cannot imagine it's gonna be any easier than jpeg to do which has been brutal.

@Jogai
Copy link

Jogai commented May 31, 2018

It such a strange recommendation, firefox does support none of the formats.

@ChrisBellew Maybe jpeg 2000/xr is somewhat like the current jpeg support 😃

@ststeiger
Copy link

ststeiger commented Jun 22, 2018

Firefox already supports webp.
But apparently, the people doing the release are incapable/unwilling of activating '--with-system-webp':.
Anyway, Firefox is very quickly becoming irrelevant.
Edge and IE already are, except for die-hard corporate environments with a backwards-compatiblity complex.
Chrome and Safari are really all that counts right now, and that will only get worse in the future.
And the way things are going for the overpriced iPad and the iPhone and other iCrap, Safari just might not going to stay around that much longer.

I'm going to throw a discrete party once that happens.
The real reason why webp isn't that successful, is webp itselfs.
https://news.ycombinator.com/item?id=13021845

But one thing that's going for webp is that we'd finally have 16 million color support for animated images - the archaic 256 color palette sported by gifs is really a disgrace in 2018.
Sure, you can use HTML5 videos to work around that, but using video formats for animated pictures is just even more stupid.

And despite the technical reasons, webm is an excellent format, simply because it's not covered by a plethora of bullshit patents, like mp*.

It's sad ogg and webm didn't establish themselfs because dickheads like Microsoft and Apple used those patents to keep out open-source. Their move/act-of-desperation to Linux/Unix today just goes a long way towards saying that their strategy failed epically, at least on the server.

Just look at all the hassle you have to go through if you want to write/release an application that supports mp3/mp4.

Sadly, that means we will only ever have windows/OsX support for webp by the time there is Office/AppleWorks for Linux.

But as Chromebooks outsell both iPad and traditional laptop sales by volume, rest assured - that day will come - eventually.
And so will the day that google-docs in offline-mode reaches feature-parity with ms-office.
The day of reckoning, so to say.

@simeyla
Copy link

simeyla commented Jun 27, 2018

They can recommend all they like, the browser support for those formats is terrible!

@JimBobSquarePants That is precisely WHY many people use a library like this. Because they need to automate the creation of JPG / WEBP / PNG files based on inconsistent browser support.

I need transparency, and I've been astonished as to how good WEBP is at keeping the filesize low. This works for all my Chrome desktop and mobile users. Then I need to create quantified PNG for Safari / IE separately. You guys are talking as if lack of support means you can't use it at all, but with a PICTURE element you just throw them both in and you're done.

Again, this is the whole reason I'm even looking at this because I need to auto-generate both and be able to change parameters easy to get best quality to filesize possible.

@JimBobSquarePants
Copy link
Member

@simeyla

That is precisely WHY many people use a library like this. Because they need to automate the creation of JPG / WEBP / PNG files based on inconsistent browser support.

In your opinion. Plenty of other applications for this library actually. Web dev is a small fish in a big pond.

If you need transparency have you investigated palletized png's? You shouldn't be using png for photo style images anyway, it's the wrong format.

I don't need WebP just now and it's both incredibly complicated and way down my priority list so if you want it, submit a PR and get things moving.

@ststeiger

Firefox already supports webp.

No it doesn't. It has a partially complete leaky decoder.

@simeyla
Copy link

simeyla commented Jun 29, 2018

@JimBobSquarePants 'Many' is an ambiguous term I realize! I mentioned it mainly because it seemed ironic you seemed to be 'writing off' WebP for lack of browser support when the <picture> tag exists and your library makes it super easy to create images in different formats ;-)

I am using palletized PNGs with alpha. Fortunately the images I need alpha for (3d renders) are very well suited to this (and I'm fine tuning them based on number of colors). In my tests I'm been quite amazed how well WebP is working and I have a very high percentage of Chrome / Android users so I was looking for a way to support all of them.

I'm very glad to see libraries like yours existing and being actively worked on, but also somewhat disappointed in Microsoft that they don't have anything to offer themselves. I started using NodeServices to link to Javascript libraries and while I've got it up and running it's caused more than a few headaches this week piecing everything together.

Thanks for your reply. Hope to be able to use your library soon for some other parts of the site :)

@ststeiger
Copy link

ststeiger commented Jul 3, 2018

@simeyla: SkiaSharp does support WebP, so just use it for that. As long as you deploy the application in an environment you control, the native library for Skia is not a problem.

Example here.
just change
using (SKData p = img.Encode(SKImageEncodeFormat.Png, 100))
to
using (SKData p = img.Encode(SKImageEncodeFormat.Webp, 100))

and return the image as byte-array/stream/streamresult.

@martonx
Copy link
Contributor

martonx commented Nov 19, 2018

As I see Firefox will completly support webP in two months. Latest MS Edge support webp also. So only Safari (as always…) will lack support of webp. So please warm up again this thread, and add webp support into ImageSharp. If I can help in anything about webp support (except the concrete development), please contact with me!

@JimBobSquarePants
Copy link
Member

@martonx I'm afraid concrete development would be exactly the help we would require just now. Supporting the format will definitely be a focus post V1 but we cannot apply any effort towards it just now as we simply don't have the people and time.

@JimBobSquarePants JimBobSquarePants added this to the Future milestone Nov 19, 2018
@martonx
Copy link
Contributor

martonx commented Nov 19, 2018

Thank you very much! And again, if I can help to test / anything except concrete development, please contact with me.

@ststeiger
Copy link

ststeiger commented Nov 19, 2018

I am interestet in coding this.
I just don't know if I will have the time.

Note for anybody interested:
There is a simple Java-Decoder here:
https://sourceforge.net/p/javavp8decoder/code/ci/master/tree/src/net/sf/javavp8decoder/imageio/

git clone https://git.code.sf.net/p/javavp8decoder/code javavp8decoder-code

JCodec also has an encoder and decoder:
http://jcodec.org/
https://github.com/jcodec/jcodec

And there is an encoder & decoder written in go here:
https://github.com/chai2010/webp
Usage:
https://stackoverflow.com/questions/8340751/webp-encoder-decoder-in-go

Simple decoder in go:
https://github.com/golang/image/blob/master/webp/decode.go

@JimBobSquarePants
Copy link
Member

Thanks @ststeiger 👍

If you get around to making a start before we do please let us know and we'll provide any assistance you require.

@martonx
Copy link
Contributor

martonx commented Mar 1, 2019

Do you have any news for this ticket?

@JimBobSquarePants
Copy link
Member

@martonx No movement I'm afraid.

@ErcinDedeoglu
Copy link

Watching.

@brianpopow brianpopow self-assigned this Jan 6, 2020
@brianpopow
Copy link
Collaborator

I am working on support for webp. So far decoding of lossless images is almost done. I will continue with decoding lossy after that. Its still alot of work to do, though. We have a gitter subchannel Formats, where i post regular updates on this.

@lofcz
Copy link
Contributor

lofcz commented Jan 27, 2020

@brianpopow any updates? Really looking forward this

@brianpopow
Copy link
Collaborator

@lofcz so far lossless decoding works fine now. Im in the middle of implementing decoding lossy images. Im making progress every day, but its hard to estimate when it will be done. I guess i have 50% done for decoding lossy images so far.

After that there is still the encoding part which i need to tackle. This will also take some time.

@JimBobSquarePants
Copy link
Member

@molinch We're actually making fantastic progress with the managed implementation.

#1271 (comment)

@brianpopow has gotten a bit of help from @stevetemple and am sure would appreciate any more.

Bindings, on the surface look like a reasonable solution but don't allow us the flexibility we require to work with multiple pixel formats in a performant manner plus they add a huge level of complexity to deployment.

@stevetemple
Copy link
Contributor

I was planning on finishing up the bits I've started tonight and that should get us pretty close to having a working lossless encoder that matches the reference implementation in size of file produced. It'll need a bunch of refactoring and tests. Lossless is a bit further off by the looks of it, but good progress is being made.

@JwanKhalaf
Copy link

Hi folks 👋

In the .NET Core application I am working on. I have a requirement where an uploaded jpeg is to be resized, then saved as a .webp format into S3 on AWS.

Can we have an update on the status of webp in ImageSharp, please? Browser support is really picking up. Safari will be supporting webp soon. Firefox and Chrome/Edge already do.

Also, many thanks for your efforts with this library. Your hard work is super appreciated ❤

@JimBobSquarePants
Copy link
Member

@JwanKhalaf There's an open (work in progress) PR. #1271

You can see the status there. Code contributions welcome.

@brianpopow brianpopow linked a pull request Nov 10, 2020 that will close this issue
4 tasks
@brianpopow brianpopow linked a pull request Feb 17, 2021 that will close this issue
4 tasks
@RouR
Copy link

RouR commented Mar 5, 2021

PR #1271 is done.
PR #1552 is waiting to merge.
I hope it will be done soon.

@JimBobSquarePants
Copy link
Member

Yep, we're very close! We need to do a final performance and API sanity check though.

I've already identified performance issues with Huffman decoding/encoding but we need to document them via profiling to allow work to be done there.

If anyone reading this thread want to profile encoding and encoding and add the info here that would be great. Better yet, if someone want to do some performance work in that area we can finally get it over the line!

@JimBobSquarePants JimBobSquarePants modified the milestones: Future, 1.1.0 Mar 15, 2021
@TeeRodFl
Copy link

I appreciate you continuing this effort. The lib is working great for my small time dev projects and its all c#!

Just wanted to let you know

@aloksharma1
Copy link

hey guys, just wanted to ask is this done?

@JimBobSquarePants
Copy link
Member

The code would be merged and the issue closed if that was the case. We’re pretty close now. I plan on a thorough review this week.

@AaFortner
Copy link

FYI, I've started implementing animation decode support. Note that I went into this more out of curiosity and for self education than to contribute changes and simply ended up getting much farther along with it that I had intended or expected. As such, I went at it somewhat backwards, so unfortunately there are no units tests yet and, more pertinently, no PR yet. If I find time to flesh it out and tidy it up, I'll advance it, but if not, feel free to carry on with what I've started. Or, heck, feel free to ignore it too. I won't mind. :-)

For reference:
https://github.com/bytehydrant/ImageSharp/tree/webp-animation

What's done:

  • All animation frame loading (for lossy and lossless)
  • Alpha blending (for lossy)
  • Clipped frame support (i.e. the cases where some frames explicitly provide fewer pixels than previous frames, with the expectation that the other pixels are copied from previous frames)
  • Did a significant rewrite of WebpDecoderCore.Decode and several of the chunk helpers to make their roles and return values more focused. Apologies if I've stepped on any toes here. Rewriting it made it much easier to work in a clean frame decode loop.
  • Confirmed existing tests continue to pass (except one jpeg test, which failed but looked unrelated to the changes)

What's not done:

  • Alpha blending (for lossless)
  • Restore to background (i.e. the cases that blend with a constant background color instead of the previous frame)
  • Test collateral and tests

@brianpopow
Copy link
Collaborator

@bytehydrant: Thanks for sharing, I will definitely take a look when I will start working on the animation feature.
I dont want to add more features to the current webp branch though. First I want to get this state into the master branch before tackling animation.

@martonx
Copy link
Contributor

martonx commented Sep 24, 2021

Hi all, is there any news when could be merged this new feature into main branch?

@JimBobSquarePants
Copy link
Member

I’m afraid it’s simply a matter of resources and priority. I’m focused right now on getting the Fonts and Drawing libraries up to a Release Candidate standard so cannot dedicate the time to focus on reviewing this PR.

If someone else can step up and review (and provide PRs for fixes for potential issues) then that would be incredibly helpful.

@artemderiddev
Copy link

watch

@JimBobSquarePants
Copy link
Member

JimBobSquarePants commented Oct 23, 2021

OK Peeps, Initial WebP support has been merged into our master branch and is available in our MyGet feed.

Now we need you to step up and help us out to make it go fast! #1786

@JwanKhalaf
Copy link

Amazing! Thank you very much to all that contributed towards WebP support ♥

Is there documentation available? I was searching through the documentation site (top right search box) for webp but nothing was coming up.

I wanted to know how I can convert a .jpg to .webp

Thanks so much again.

@JimBobSquarePants
Copy link
Member

Thanks!

WebP support isn't fully released yet and is only available via our development build on MyGet so we haven't published docs yet.

Saving as WebP will work in the same manner as all saving in other formats, we have all the equivalent methods in place.

@utillity
Copy link

utillity commented Mar 9, 2022

awesome guys!! how can I get informed when it's released?
great work!

@brianpopow
Copy link
Collaborator

@utillity webp is supported with the release of 2.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.