8000 webp: don't reject VP8X that isn't just VP8 + alpha · golang/image@3a743ba · GitHub
[go: up one dir, main page]

Skip to content

Commit 3a743ba

Browse files
narrowizardnigeltao
authored andcommitted
webp: don't reject VP8X that isn't just VP8 + alpha
We already support VP8 + alpha, but reject e.g. VP8 + EXIF. After this commit, we still don't implement VP8 + EXIF (or ANIM, ICCP, etc.), but we now silently ignore the EXIF chunk instead of rejecting it. Fixes golang/go#25738, golang/go#38341 Change-Id: I4e9cdb718f0768f34336eab9528b82d2c40a3ee1 GitHub-Last-Rev: a0c2e53 GitHub-Pull-Request: #5 Reviewed-on: https://go-review.googlesource.com/c/image/+/249445 Trust: David Symonds <dsymonds@golang.org> Reviewed-by: Nigel Tao <nigeltao@golang.org>
1 parent 972c09e commit 3a743ba

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

webp/decode.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,22 +126,23 @@ func decode(r io.Reader, configOnly bool) (image.Image, image.Config, error) {
126126
alphaBit = 1 << 4
127127
iccProfileBit = 1 << 5
128128
)
129-
if buf[0] != alphaBit {
130-
return nil, image.Config{}, errors.New("webp: non-Alpha VP8X is not implemented")
131-
}
129+
wantAlpha = (buf[0] & alphaBit) != 0
132130
widthMinusOne = uint32(buf[4]) | uint32(buf[5])<<8 | uint32(buf[6])<<16
133131
heightMinusOne = uint32(buf[7]) | uint32(buf[8])<<8 | uint32(buf[9])<<16
134132
if configOnly {
133+
if wantAlpha {
134+
return nil, image.Config{
135+
ColorModel: color.NYCbCrAModel,
136+
Width: int(widthMinusOne) + 1,
137+
Height: int(heightMinusOne) + 1,
138+
}, nil
139+
}
135140
return nil, image.Config{
136-
ColorModel: color.NYCbCrAModel,
141+
ColorModel: color.YCbCrModel,
137142
Width: int(widthMinusOne) + 1,
138143
Height: int(heightMinusOne) + 1,
139144
}, nil
140145
}
141-
wantAlpha = true
142-
143-
default:
144-
return nil, image.Config{}, errInvalidFormat
145146
}
146147
}
147148
}

0 commit comments

Comments
 (0)
0