Fix alpha/fuzzy border issue with new webp decoder for images with with transparent background

Fixes #14339
This commit is contained in:
Bjørn Erik Pedersen
2026-01-02 16:22:25 +01:00
parent b8a2c10d06
commit e9b9b36f46
6 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -142,7 +142,7 @@ func (d *WebpCodec) Decode(r io.Reader) (image.Image, error) {
frames := make([]image.Image, len(destination.Bytes())/frameSize)
for i := 0; i < len(frames); i++ {
frameBytes := destination.Bytes()[i*frameSize : (i+1)*frameSize]
frameImg := &image.RGBA{
frameImg := &image.NRGBA{
Pix: frameBytes,
Stride: stride,
Rect: image.Rect(0, 0, w, h),
@@ -153,7 +153,7 @@ func (d *WebpCodec) Decode(r io.Reader) (image.Image, error) {
return img, nil
}
img := &image.RGBA{
img := &image.NRGBA{
Pix: destination.Bytes(),
Stride: stride,
Rect: image.Rect(0, 0, w, h),
@@ -372,7 +372,7 @@ sourcefilename: ../testdata/giphy.gif
sourcefilename: ../testdata/sunset.jpg
-- layouts/home.html --
Home.
{{ $fuzzyCircle := resources.Get "fuzzycircle.png" }}
{{ $fuzzyCircle := resources.Get "fuzzycircle.webp" }}
{{ $highContrast := resources.Get "highcontrast.webp" }}
{{ $sunset := resources.Get "sunset.jpg" }}
{{ $sunsetGrayscale := $sunset.Filter (images.Grayscale) }}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB