chai2010 / chai2010/webp

The decoder incorrectly decoded the image to invalid RGBA values 错误地将图像解码为不合法的RGBA值

Open
#81 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
723
Forks
113
PR merge metrics
No merged PRs in 30d

Description

```golang
package main

import (
"fmt"
_ "github.com/chai2010/webp"
"image"
"os"
)

func main() {
file, err := os.Open("img.webp")
if err != nil {
fmt.Println("open file error:", err)
return
}
defer file.Close()

img, _, err := image.Decode(file)
if err != nil {
fmt.Println("decode error:", err)
return
}

switch v := img.(type) {
case *image.RGBA:
fmt.Println("This is RGBA")
case *image.NRGBA:
fmt.Println("This is NRGBA")
default:
fmt.Printf("Other type: %T\n", v)
}

bounds := img.Bounds()
width, height := bounds.Dx(), bounds.Dy()
for y := 0; y < height; y++ {
for x := 0; x < width; x++ {
r, g, b, a := img.At(x, y).RGBA()
r8, g8, b8 := uint8(r>>8), uint8(g>>8), uint8(b>>8)
a8 := uint8(a >> 8)

if a8 == 0 && (r8 != 0 || g8 != 0 || b8 != 0) {
fmt.Printf("Pixel(%d,%d): R=%d, G=%d, B=%d, A=%d\n", x, y, r8, g8, b8, a8)
}
}
}
}

```

```
Output:
This is RGBA
Pixel(176,0): R=0, G=1, B=0, A=0
Pixel(177,0): R=0, G=1, B=0, A=0
Pixel(178,0): R=0, G=1, B=0, A=0
Pixel(179,0): R=0, G=1, B=0, A=0
Pixel(180,0): R=0, G=1, B=0, A=0
Pixel(181,0): R=0, G=1, B=0, A=0
Pixel(182,0): R=0, G=1, B=0, A=0
Pixel(183,0): R=0, G=1, B=0, A=0
Pixel(184,0): R=0, G=1, B=0, A=0
Pixel(185,0): R=0, G=1, B=0, A=0
Pixel(186,0): R=0, G=1, B=0, A=0
Pixel(187,0): R=0, G=1, B=0, A=0
Pixel(188,0): R=0, G=1, B=0, A=0
Pixel(189,0): R=0, G=1, B=0, A=0
Pixel(190,0): R=0, G=1, B=0, A=0
Pixel(191,0): R=0, G=1, B=0, A=0
Pixel(192,0): R=108, G=109, B=104, A=0
Pixel(193,0): R=110, G=108, B=104, A=0
Pixel(194,0): R=111, G=107, B=104, A=0
Pixel(195,0): R=113, G=107, B=104, A=0
Pixel(196,0): R=116, G=105, B=104, A=0
Pixel(197,0): R=119, G=103, B=104, A=0
Pixel(198,0): R=121, G=103, B=104, A=0
Pixel(199,0): R=116, G=105, B=104, A=0
Pixel(200,0): R=120, G=126, B=117, A=0
Pixel(201,0): R=115, G=129, B=117, A=0
```

Reproducible image link: https://s2.loli.net/2025/08/22/V39dLFnrmzv27xu.webp

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the provided Go reproducer, the image.Decode entry point, and the linked WebP image to confirm the transparent pixels with nonzero RGB values. Trace the decoder path that produces the RGBA image and add a regression check for the reported pixels; done means decoding no longer yields the invalid RGBA values.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.