-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Add image processing support for WebP image resources #5924
Comments
|
So, currently I think the best we could do is to encode it to "something differeng", e.g. JPEG, but we should probably have some syntax for that. |
@bep do you plan to implement the conversion and webp manipulation? if not, could we agree on specs so I can suggest an implementation? My guess would be to implement a
Code-wise, we'd have to parse the second argument to match parameters for the library used, but this would allow using it for other conversions in the future. |
@geoffreybauduin one the API side this is mostly about adding another MIME type / image format. But that just scratches the surface of this. The main problem here is that there is no native Go webp encoder. |
Is having a native webp encoder a must-have for you or would you be fine with a C library? |
I can just recall that there was a solution available and it is still available #7155 |
@blaubaer, your PR exec's |
How about something like |
@idarek, both of those projects bind to a C library. That's not native Go. |
@moorereason There is currently not planned any native implementation of WebP in Golang (for encoding). Therefore there are only 2 ways to support that: Either calling a binary OR embedding C-Code directly into the library. For sure we can wait until someone is doing it (the porting - you're free to code) and do not implement such important stuff into Hugo (which seems to be important for SEO ratings too - if it is important for Lighthouse we can assume it is important for Google, too) OR implement one of the 2 options named above. For now I solved me issue (although it is not great) with a image proxy that is doing transparent WebP encoding for me. Sad to use such stuff. |
@blaubaer may hit a point. If you look google page they also referring to use cwebp to convert images. Because of that I don't believe creating native Go converter will happen in a future. @pawelgrzybek recently posted his method of implementing WebP and AVIF into Hugo using rendering hooks. The encoding is done prior to Hugo build and is not using image.resize aspect, however the output and performance (from PageSpeed Insight view) is impressive. |
I started doing the same. What would be useful though, is being able to get a list of images with a match and obtain their metadata such as width/height for sorting or addint the attributes in the srcset and so on.
A quick glance a the native Go image library hints that reading such values for webp is possible.
|
@pawelurbanski: you can obtain the width and height of a webp image using the For a page resource:
For a global resource:
If using a global resource, it must be in the |
I don't think that would work if you fingerprint your images. Could be wrong though |
Thanks, @jmooring |
Dont want to sound rude but you guys dont also think its fucking dissapointing that the legendary Imageformat (WEBP) which is developed by Google is not usable in Googles own programming language? While WEBP was found back in 2010 .. I think its a shame. Not on Hugo, but on goLang in general |
I tried this code
but I get an error:
The .ResourceType is correctly identified as image. If I replace that with a jpg version it works.
The text was updated successfully, but these errors were encountered: