webp icon indicating copy to clipboard operation
webp copied to clipboard

Delete metadata without compressing

Open AgentCosmic opened this issue 6 years ago • 2 comments

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

AgentCosmic avatar Feb 19 '19 09:02 AgentCosmic

did you manage to find a solution?

LazarenkoA avatar Jan 09 '23 19:01 LazarenkoA

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

geokdev-afk avatar Sep 03 '23 11:09 geokdev-afk