Skip to content

Commit fb8cde9

Browse files
authored
fix(webp): Missing oiio:UnassociatedAlpha on input (AcademySoftwareFoundation#5020)
Like other file formats, the returned ImageSpec should indicate if the image contains unassociated alpha. This was an oversight in AcademySoftwareFoundation#4770. Test added. Signed-off-by: Brecht Van Lommel <[email protected]>
1 parent ae120af commit fb8cde9

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/webp.imageio/webpinput.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,11 @@ WebpInput::open(const std::string& name, ImageSpec& spec,
214214
// Make space for the decoded image
215215
m_decoded_image.reset(new uint8_t[m_spec.image_bytes()]);
216216

217-
if (config.get_int_attribute("oiio:UnassociatedAlpha", 0) == 1)
217+
if (config.get_int_attribute("oiio:UnassociatedAlpha", 0) == 1) {
218218
m_keep_unassociated_alpha = true;
219+
if (m_spec.alpha_channel != -1)
220+
m_spec.attribute("oiio:UnassociatedAlpha", 1);
221+
}
219222

220223
seek_subimage(0, 0);
221224
spec = m_spec;

testsuite/webp/ref/out-webp1.1.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ Reading ../oiio-images/webp/4.webp
1818
SHA-1: 8F42E3DCCE6FE15146BA06C440C15B7831F60572
1919
channel list: R, G, B
2020
oiio:ColorSpace: "srgb_rec709_scene"
21+
Reading rgba.webp
22+
rgba.webp : 64 x 64, 4 channel, uint8 webp
23+
SHA-1: 897256B6709E1A4DA9DABA92B6BDE39CCFCCD8C1
24+
channel list: R, G, B, A
25+
oiio:ColorSpace: "srgb_rec709_scene"
26+
oiio:UnassociatedAlpha: 1

testsuite/webp/run.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@
1111
# a lossy format and is not stable under the round trip
1212
# command += rw_command (OIIO_TESTSUITE_IMAGEDIR, f,
1313
# extraargs='-attrib compression lossless')
14+
15+
command += oiiotool ("--create 64x64 4 -o rgba.webp")
16+
command += info_command ("rgba.webp", "--iconfig oiio:UnassociatedAlpha 1", safematch=True)

0 commit comments

Comments
 (0)