chai2010 / webp

WebP decoder and encoder for Go (Zero Dependencies).
http://godoc.org/github.com/chai2010/webp
BSD 3-Clause "New" or "Revised" License
522 stars 88 forks source link

Delete metadata without compressing #22

Open AgentCosmic opened 5 years ago

AgentCosmic commented 5 years ago

I'd like to be able to remove metadata from a webp file without losing quality.

LazarenkoA commented 1 year ago

did you manage to find a solution?

georgekakarlis commented 11 months ago

i guess something with the DecodeRGBA function. you remove everything and you have a bare-pixels image. then you encode it again without the metadata. something like : ` //: Decode the Image img, err := webp.DecodeRGBA(data) if err != nil { log.Fatalf("Failed to decode webp: %v", err) }

//  Re-encode the Image
new_data, err := webp.EncodeRGBA(img, 90)  // Here 90 is the quality, adjust as needed
if err != nil {
    log.Fatalf("Failed to encode webp: %v", err)
}

// Save the New Image
err = ioutil.WriteFile("output.webp", new_data, 0644)  //new_data here is the re-encoded "barebones" image.
if err != nil {
    log.Fatalf("Failed to write to file: %v", err)
}`

for reference : https://pkg.go.dev/github.com/chai2010/webp#DecodeRGBA https://pkg.go.dev/image#RGBA