Skip to content

Discord breaks webp image on upload #159

@nico

Description

@nico

wow.zip

The webp file in the attached zip is an animated lossless webp that displays fine in all browsers I've tried.

If I upload the webp file in the attached zip, Discord:

a) fails to show it
b) turns it into a file that no longer renders in browsers

The webp has different rects for different animation frames – new frames don't store data that's identical to old frames.

For b), it looks like lilliput takes the width and height of the last animation frame and writes that into the vp8x header. That is incorrect, since the last frame is smaller than the animation.

For animated images, ideally the original size from the vp8x header would be written to the output unmodified. Failing that, the dimensions of the first animation frame are probably a better guess than the dimensions of the last animation frame.

It also looks like the flags byte in the vp8x header isn't quite right. On input, they are 0x12. In the file that comes back it's 0x0a.

0xa means "has exif, has animation". Discord added an (empty) EXIF chunk, so it's fine that that bit gets added. But the 0x10 bit, which means has alpha, got cleared. This animation definitely has alpha.

If I manually fix up the dimensions in the vp8x header, the image starts playing in browsers. But e.g. Safari no longer shows the transparent pixels as transparent, because this bit got cleared.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions