Better animated thumbs #65

Open
opened 2025-01-27 16:17:08 -06:00 by Zankaria · 4 comments
Zankaria commented 2025-01-27 16:17:08 -06:00 (Migrated from gitlab.leftypol.org)

Right now, the thumb_keep_animation_frames limits the maximum number of frames in the previews and requires the the thumb_ext option to be set to empty or gif, which is undesirable since we want our previews to be in the small webp.
An extra thumb_animated_ext option or something similar to generate animated previews in a desired format needs to be added. webm is preferable to gif due to it's better compression, but I am not sure if the browser treats them like an image. Investigation is required

Right now, the `thumb_keep_animation_frames` limits the maximum number of frames in the previews and requires the the `thumb_ext` option to be set to empty or `gif`, which is undesirable since we want our previews to be in the small `webp`. An extra `thumb_animated_ext` option or something similar to generate animated previews in a desired format needs to be added. `webm` is preferable to `gif` due to it's better compression, but I am not sure if the browser treats them like an image. Investigation is required
IFA commented 2025-02-09 12:30:51 -06:00 (Migrated from gitlab.leftypol.org)

Investigation is required

converting a user gif into a thumbnail can be done like this (imagemagick 6.9.11)

convert original.gif -coalesce -filter Lanczos -resize "255x255>" -deconstruct miff:- | convert miff:- -define webp:method=6 -quality 50 thumb.webp

the settings can be adjusted to taste, currently results in:

images ![original](/uploads/ee1431e902791605bbbb0438125ca9ab/original.gif)

random gif from images, a square, 904x904px, 245.5 kb

thumb

255x255px, 53.0 kb

alternate approaches:

  • using gif2webp handles conversion ok but does not have resize, meaning we have to do a more complicated 2-pass for questionable improvements

  • ffmpeg if you ever want to extend functionality to generating thumbnails of assorted videos, for gif to webp alone it's computationally intense

lmk if this helps

>Investigation is required - [animated webps exist and are supported by major browsers](https://developers.google.com/speed/webp/faq#:~:text=webp%20animation%20support%20). using a webm would turn the thumb into a video element, undesired converting a user gif into a thumbnail can be done like this (imagemagick 6.9.11) `convert original.gif -coalesce -filter Lanczos -resize "255x255>" -deconstruct miff:- | convert miff:- -define webp:method=6 -quality 50 thumb.webp` the settings can be adjusted to taste, currently results in: <details><summary>images</summary> ![original](/uploads/ee1431e902791605bbbb0438125ca9ab/original.gif) random gif from images, a square, 904x904px, 245.5 kb ![thumb](/uploads/38fbb2042f492ae8b2d88e426e1b12f9/thumb.webp) 255x255px, 53.0 kb </details> alternate approaches: - using [gif2webp](https://developers.google.com/speed/webp/docs/gif2webp) handles conversion ok but does not have resize, meaning we have to do a more complicated 2-pass for questionable improvements - [ffmpeg](https://superuser.com/questions/1408120/how-do-i-generate-webp-preview-animations-using-ffmpeg) if you ever want to extend functionality to generating thumbnails of assorted videos, for gif to webp alone it's computationally intense lmk if this helps

All of our thumbnails are webp, including gifs which we convert to animated webp.

I could only make it work using convert. gif2webp was subpar for thumbnail because of resize options and ffmpeg too intensive.

https://github.com/perdedora/nicochan/blob/master/inc/image.php#L367-L418

All of our thumbnails are webp, including gifs which we convert to animated webp. I could only make it work using convert. gif2webp was subpar for thumbnail because of resize options and ffmpeg too intensive. https://github.com/perdedora/nicochan/blob/master/inc/image.php#L367-L418
Owner

webp can be animated!?

webp can be animated!?
@Zankaria wrote in https://forgejo.leftypol.org/leftypol/leftypol/issues/65#issuecomment-350: > webp can be animated!? Yes. https://magalichan.com/media/b86e0279efef865522ce2fcd5ed5c02ed8c398ad8f7efebacb5f6c74b13a7fcf_t.webp
Sign in to join this conversation.
No labels
Bug
Proposal
Request
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: leftypol/leftypol#65
No description provided.