Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebP: Images decoded with yellow tint #864

Open
gotson opened this issue Nov 14, 2023 · 1 comment
Open

WebP: Images decoded with yellow tint #864

gotson opened this issue Nov 14, 2023 · 1 comment

Comments

@gotson
Copy link
Contributor

gotson commented Nov 14, 2023

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.

@haraldk haraldk changed the title WebP images decoded with yellow tint WebP: Images decoded with yellow tint Nov 14, 2023
@haraldk
Copy link
Owner

haraldk commented Nov 14, 2023

Hi @gotson!

Thanks for the samples! I believe this is the same issue as reported in #785 .

I haven't been able to find the exact problem, but I believe there is some small rounding or other error that accumulates during decoding, as the problem is typically most visible in the lower right corner of the decoded image.

I will look into it, but any help on pinpointing or fixing the issue would be greatly appreciated! 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants