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

NullPointerException while reading an WebP animated image #702

Closed
XspeedPL opened this issue Oct 2, 2022 · 2 comments
Closed

NullPointerException while reading an WebP animated image #702

XspeedPL opened this issue Oct 2, 2022 · 2 comments

Comments

@XspeedPL
Copy link

XspeedPL commented Oct 2, 2022

Describe the bug
NullPointerException while trying to read an otherwise browser-viewable WebP animated image frame

Version information

  1. The version of the TwelveMonkeys ImageIO library in use.
    3.9.0-20220929.130202-41

  2. The exact output of java --version (or java -version for older Java releases).
    openjdk version "17.0.4.1" 2022-08-12 LTS
    OpenJDK Runtime Environment Zulu17.36+17-CA (build 17.0.4.1+1-LTS)
    OpenJDK 64-Bit Server VM Zulu17.36+17-CA (build 17.0.4.1+1-LTS, mixed mode, sharing)

  3. Extra information about OS version, server version, standalone program or web application Windows 10 [Version 10.0.19044.2075]

To Reproduce

  1. Run the below sample code
  2. See error

Expected behavior
Image frame loaded for reading

Example code

var source = new URI("https://cdn.7tv.app/emote/60dbea82e3e5887a4a95e1db/2x").openStream();
var in = ImageIO.createImageInputStream(source);
var reader = ImageIO.getImageReaders(in).next();
int numFrames = reader.getNumImages(true);
System.out.println("Frames: " + numFrames);

for (int frameIndex = 0; frameIndex < numFrames; ++frameIndex) {
	var img = reader.read(frameIndex);
	System.out.println("W: " + img.getWidth() + ", H: " + img.getHeight());
}

Sample file(s)
https://cdn.7tv.app/emote/60dbea82e3e5887a4a95e1db/2x

Stack trace

java.lang.NullPointerException: Cannot invoke "java.awt.image.WritableRaster.getHeight()" because "<parameter1>" is null
at com.twelvemonkeys.imageio.plugins.webp.WebPImageReader.opaqueAlpha(WebPImageReader.java:640)
at com.twelvemonkeys.imageio.plugins.webp.WebPImageReader.read(WebPImageReader.java:439)
at java.desktop/javax.imageio.ImageReader.read(ImageReader.java:938)

Screenshots

Additional context

@haraldk
Copy link
Owner

haraldk commented Oct 3, 2022

Thanks for reporting!

There seems to be an incorrect assumption that there is always alpha in animation frames...
I'll fix.

haraldk added a commit that referenced this issue Oct 6, 2022
@haraldk
Copy link
Owner

haraldk commented Oct 6, 2022

Fixed.

@haraldk haraldk closed this as completed Oct 6, 2022
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