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: Image decoded as green #734

Open
gotson opened this issue Mar 6, 2023 · 6 comments
Open

WebP: Image decoded as green #734

gotson opened this issue Mar 6, 2023 · 6 comments

Comments

@gotson
Copy link
Contributor

gotson commented Mar 6, 2023

Describe the bug
A specific webp image turns green when converted to jpeg or png.

Version information

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

3.9.4. I also tried with 3.10.0-SNAPSHOT.

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

openjdk version "1.8.0_332"
OpenJDK Runtime Environment Corretto-8.332.08.1 (build 1.8.0_332-b08)
OpenJDK 64-Bit Server VM Corretto-8.332.08.1 (build 25.332-b08, 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.

I tested on macOS 13.2.1.

User reported on Windows 11.

Expected behavior
The converted image should look like the original.

Sample file(s)

001e.zip

Screenshots

Additional context
This was reported in gotson/komga#1077

@gotson
Copy link
Contributor Author

gotson commented Mar 6, 2023

Hi Harald, i tested this with NightMonkeys ImageIO, and it works fine, so it seems to be an issue with TwelveMonkeys.

The webp image doesn't seem to have any specific features:

> webpinfo 001e.webp2023
File: 001e.webp
RIFF HEADER:
  File size: 563282
Chunk VP8  at offset     12, length 563270
  Width: 1920
  Height: 3001
  Alpha: 0
  Animation: 0
  Format: Lossy (1)
No error detected.

@haraldk
Copy link
Owner

haraldk commented Mar 6, 2023

Thanks for reporting!

I can reproduce the result with your attached sample file.

I don't have an immediate fix, unfortunately, so I need to look into why this is happening... Any help appreciated! 😀

@haraldk haraldk changed the title webp image turns green when converted to jpeg or png WebP: Image decoded as green Mar 7, 2023
@KoenDG
Copy link
Contributor

KoenDG commented Sep 29, 2023

I thought I'd try my hand at this, but after 2 days I give up.

It happens for JPG, BMP, PNG, TGA and TIFF. Other file types marked as writable don't generate a file. So I concluded it wasn't a writer issue.

Having learned that, I focused on the WebPImageReader, but comparing to other webp images, nothing seems out of the ordinary.

So in the end, I wasn't able to find anything.

Except for the fact that the example images here: https://developers.google.com/speed/webp/gallery2#webp_links

Only write PNG and TGA, but not JPG and BMP. I didn't check with the others. With the same code I used to test the image provided here.

Which is just the example code from the readme that does

try (ImageInputStream input = ImageIO.createImageInputStream(file)) {

With only default params and a write to the format I want added at the end.

Nothing serious, just thought I'd try this out.

@haraldk
Copy link
Owner

haraldk commented Sep 29, 2023

Thanks @KoenDG!

True, it's not a writer issue, you can see the images decodes as green only by reading and displaying the image (in Java).

(The fact that some formats don't write all images probably has to do with the pixel layout, more specifically, standard JPEG and BMP plugins doesn't write images with alpha, see the respective plugin Spi's canEncodeImage(ImageTypeSpecifier) method)

@KoenDG
Copy link
Contributor

KoenDG commented Sep 29, 2023

Something in general I'd like to vent frustration at, is the lack of tools around the internet to properly analyze images for their technical details. Or maybe I'm just not "in the know" for this.

Given how this happens for non of the google example images, I thought "there's probably something really specific going on, what tool could print out the technical details for this image, stuff at the bit level or in hexadecimal".

But even looking at it with a hex editor was gibberish.

I also couldn't find another webp image with 24 pixel depth like the one at issue here to compare.

@haraldk
Copy link
Owner

haraldk commented Oct 1, 2023

@KoenDG Not sure what kind of details you expect to find? Tools like ExifTool or other command line imaging tools like ImageMagick might help? There are also more sophisticated tools in the "forensics" category that might help here.

Most of the time I'm just using a plain hex viewer/editor and do my own parsing. Especially when looking at corrupted or malformed files, this might be the only way... But as each file format is different, you often need to have an understanding of the specification for the format to make sense out of it. It's not gibberish. It's just image data... 😀

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

3 participants