Skip to content

WebP: Images decoded with yellow tint #864

@gotson

Description

@gotson

Describe the bug
Some WebP images are decoded with a yellow tint.

Version information

  1. The version of the TwelveMonkeys ImageIO library in use.
    3.10.1

  2. The exact output of java --version (or java -version for older Java releases).

openjdk 21 2023-09-19 LTS
OpenJDK Runtime Environment Temurin-21+35 (build 21+35-LTS)
OpenJDK 64-Bit Server VM Temurin-21+35 (build 21+35-LTS, mixed mode)

  1. Extra information about OS version, server version, standalone program or web application packaging, executable wrapper, etc. Please state exact version numbers where applicable.

To Reproduce
Steps to reproduce the behavior:

  1. Add the attached files as test resources for imageio-webp
  2. Run the below unit tests
  3. Check the generated PNG images, and compare to their JPG equivalent

Expected behavior
Images should look alike.

Example code

@Test
    public void test1() throws IOException {
        testReadTestData(new TestData(getClassLoaderResource("/webp/Example1.webp"), new Dimension(2144, 3200)));
    }

    @Test
    public void test2() throws IOException {
        testReadTestData(new TestData(getClassLoaderResource("/webp/Example2.webp"), new Dimension(2144, 3200)));
    }

    public void testReadTestData(TestData data) throws IOException {
        ImageReader reader = createReader();

        reader.setInput(data.getInputStream());

        for (int i = 0; i < data.getImageCount(); i++) {
            BufferedImage image = null;

            try {
                image = reader.read(i);
                File tempActual = File.createTempFile("junit-testRead-", ".png");
                System.out.println("tempActual.getAbsolutePath(): " + tempActual.getAbsolutePath());
                ImageIO.write(image, "PNG", tempActual);
            }
            catch (Exception e) {
                e.printStackTrace();
                failBecause(String.format("Image %s index %s could not be read: %s", data.getInput(), i, e), e);
            }

            assertNotNull(String.format("Image %s index %s was null!", data.getInput(), i), image);

            assertEquals(
                String.format("Image %s index %s has wrong width: %s", data.getInput(), i, image.getWidth()),
                data.getDimension(i).width,
                image.getWidth()
            );
            assertEquals(
                String.format("Image %s index %s has wrong height: %s", data.getInput(), i, image.getHeight()),
                data.getDimension(i).height, image.getHeight()
            );
        }

        reader.dispose();
    }

Sample file(s)
JPG.zip
WEBP.zip

Screenshots
282593440-845e8b38-7de4-463d-8dc8-ec5c35127e52

Additional context
I tested those images in NightMonkeys, and they decode correctly.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions