Skip to content

Use animated webp instead of gif for animated assets - #10492

Open
Soheab wants to merge 4 commits into
Rapptz:masterfrom
Soheab:webp-asset
Open

Soheab wants to merge 4 commits into
Rapptz:masterfrom
Soheab:webp-asset

Conversation

@Soheab

@Soheab Soheab commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR changes the default format of animated assets from gif to webp with animated=true and adds two new properties for convenience: .format, .size.

The main reason for this change is Discord forcing this if an asset was uploaded as an animated webp, but it also works fine if uploaded as other formats.

API Docs: https://docs.discord.com/developers/reference#image-formatting

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

@Rapptz

Rapptz commented Jul 23, 2026

Copy link
Copy Markdown
Owner
  1. Your diff is disproportionate to the change because you forgot to maintain the magic trailing comma.
  2. I think this might be potentially too much of a breaking change. Last time I changed the default format people were complaining about a bunch of things because they'd be feeding this into image libraries like PIL which do not support webp. Since I changed the default from PNG to WEBP last time for images, people did get into the habit of specifying a format for consumption afterwards but I'm not sure they did for animated images so something to keep in mind.

@Soheab

Soheab commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor Author
  1. Your diff is disproportionate to the change because you forgot to maintain the magic trailing comma.
  2. I think this might be potentially too much of a breaking change. Last time I changed the default format people were complaining about a bunch of things because they'd be feeding this into image libraries like PIL which do not support webp. Since I changed the default from PNG to WEBP last time for images, people did get into the habit of specifying a format for consumption afterwards but I'm not sure they did for animated images so something to keep in mind.
  1. Fixed!
  2. I don't really do image manipulation, but it seems to be supported now and works fine if saved as a gif (i think people do that anyways?):

Docs: https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#webp
Test:

import os

import requests
from PIL import Image

url = 'https://cdn.discordapp.com/avatars/59152242862723072/a_ddde070fdf76e2ed5c8f2645959ab5c2.webp?size=1024&animated=true' # thanks ste🅱️e

res = requests.get(url, stream=True)
image = Image.open(res.raw)

image.save('test.gif', save_all=True)
os.startfile('test.gif')

Regardless of that, assets uploaded as animated webp require the use of this format, .gif points to an unknown resource.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants