Thanks to Hugo 0.153 the support for WebP images has been greatly improved, including animated images. Sweet!
This works really well, but I recently had a case where a remote container killed the Hugo process as it ran out of memory due to multiple animated WebP files (relatively small ones like 1280x720px, but with a few hundred frames each). Currently the theme processes each reflect.IsImageResourceProcessable resources, that means animated WebP files get resized too. Hugo version 0.160 by the way.
Is there a way similar to AssertIsAnimated usable in templates, so we can potentially skip any processing step for such animated files (and just directly provide the resource as-is)?
Thank you, have a good one!
No, there is no built in detection of any property of images like “is it animated”, “does it have the color red” etc. That is something you need to add to the frontmatter and then work based on that. “The author” of a post is “aware” of what they put into the post, so if they add an animated image, they should/could add that information to however you organise your image meta data. The processing template then can check that information and build based on that.
That memory issue makes sense with animated WebP files containing hundreds of frames. Adding an animation flag in the front matter sounds like a practical workaround, especially if it lets Hugo skip resizing those files. Hopefully, a built-in check gets added in the future.