Original post

Youtube (and by extension youtube-dl) recently started to give thumbnails in the *.webp format, instead of the *.jpg format. If you try to load the *.webp files into a gdk.Pixbuf using the gdk.PixbufNewFromFile() function you get an error:

Couldn’t recognize the image file format for file “4kberLzSvx0.webp”

So I started to look at the package golang.org/x/image/webp (https://pkg.go.dev/golang.org/x/image/webp?tab=doc) but I don’t know if this package is what I am supposed to use to enable webp format support, or how to use it properly.

Does anyone here know how to load an image in webp format?

You can see my code at:

This is my test code so far:

package main

import (
        "fmt"
        "github.com/gotk3/gotk3/gdk"
        _ "golang.org/x/image/webp"
)

func main() {
        // Jpeg works fine
        loadImage("031wc2m0IWs.jpg")

        // Webp does not work
        loadImage("4kberLzSvx0.webp")
}

func loadImage(path string) *gdk.Pixbuf {

        image, err := gdk.PixbufNewFromFile(path)
        if err!=nil {
                fmt.Printf("%s", err.Error())
        }
        return image
}