Open kaedroho opened 5 years ago
What's the status of this PR?
@danihodovic it's awaiting review
Code looks good to me. One thing I'm not clear on, though: given that PillowAnimatedImage
can presumably do everything PillowImage
can do and more, is there any reason for the "choose the best backend" logic in registry.py to ever prefer PillowImage
- and if not, do we really need both classes to exist?
Code looks good to me. One thing I'm not clear on, though: given that PillowAnimatedImage can presumably do everything PillowImage can do and more, is there any reason for the "choose the best backend" logic in registry.py to ever prefer PillowImage - and if not, do we really need both classes to exist?
Good point! I've merged the two classes together now
My plan for this is to implement both animated GIF and animated WEBP support in Willow, then add logic into Wagtail so that it always transcodes animated GIFs into animated WEBP files. This fixes issues with having to save a GIF that contains more than 256 colours (which will be inevitable if we've resized the image). See discussion in https://github.com/wagtail/Willow/pull/76#discussion_r331426263
I just tried out this PR on my shop's codebase, because the Wand-based solution causes our servers to die when someone uploads a sufficiently large or complex animated GIF.
Using this code, I was able to get one of the offending GIFs to generate renditions without crashing, but they're... broken.
Here's the original (appologies for the gigantic GIF):
And here's the Image Chooser rendition:
Maybe I've done something wrong? Is there anything I can tweak to try to make Pillow generate animated GIFs in a different way, which hopefully won't break them?
Hey @coredumperror
I'm getting similar results with a different image here
I think this is just a Pillow limitation. It must be difficult saving GIF images like this which have a limit of 256 colours. I think the best solution would be for us to add support for animated webp/apng so images can be saved in those formats instead.
I think the best solution would be for us to add support for animated webp/apng so images can be saved in those formats instead.
Yes, please! Animated GIF is soooo 1990s. Hell, mosts sites that let you share GIFs just convert to mp4 video with no audio track. I wonder if that would be possible?
Hell, mosts sites that let you share GIFs just convert to mp4 video with no audio track. I wonder if that would be possible?
Hadn't thought of that before! I think we could view MP4 w/o audio as just another animated image format, so could support that if Pillow/wand does (but can always add an ffmpeg plugin if not!)
Relevant blog post: https://paulbakaus.com/2020/01/17/gifs-must-die/ Historically Wagtail has deliberately shied away from dealing with video because doing it well (handling arbitrary format conversions, extracting metadata, generating thumbnails, dealing with large file uploads...) would be as big a job as the content management side... but given that the demand for animated GIFs isn't going away, and the border between animation and video is getting ever more blurred, I think it might be time to rethink that.
I think it might be time to rethink that.
I am exceedingly glad to hear this. :)
@zerolab possibly in relation to issue #80 , is there any traction on this?
We're still very interested in Wagtail properly supporting animated whatevers (GIF, webp, mp4, etc.).
Incidentally @thenewguy makes the case for animated GIFs to be treated as "media" (i.e. no resizing and other Willlow filters) - https://github.com/torchbox/wagtailmedia/issues/127 Might that be the way to go?
I like that idea! In many cases, GIFs would be both smaller and better quality if we don't try to process them. Wagtailmedia may also be able to provide the processing code required to convert them into videos as well.
This PR adds support for animated GIFs in the Pillow backend