TwelveMonkeys
TwelveMonkeys copied to clipboard
WebP: Image decoded as green
Describe the bug A specific webp image turns green when converted to jpeg or png.
Version information
- The version of the TwelveMonkeys ImageIO library in use.
3.9.4. I also tried with 3.10.0-SNAPSHOT.
- The exact output of
java --version
(orjava -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)
- 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)
Screenshots
Additional context This was reported in https://github.com/gotson/komga/issues/1077
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.
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! 😀
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.
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)
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.
@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... 😀