Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSC2705: Animated thumbnails for media #2705

Merged
merged 5 commits into from
Feb 11, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions proposals/2705-thumbnail-requirements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# MSC2705: Animated thumbnails

Some clients would like animated versions of media for thumbnail purposes. The use cases vary, however
the common ask is frequent enough to warrant an MSC.

## Proposal

By specifying `animated=true` in the query string for a `/thumbnail`, the server SHOULD return
an animated thumbnail for the media if possible. When the parameter is `false` the server SHOULD NOT
turt2live marked this conversation as resolved.
Show resolved Hide resolved
attempt to generate a thumbnail, as many implementation do today.
turt2live marked this conversation as resolved.
Show resolved Hide resolved

If the server supports the flag, it MUST support animating the following mimetypes:
turt2live marked this conversation as resolved.
Show resolved Hide resolved
* `image/gif`
* `image/png` (for animated PNGs - non-animated PNGs cannot be supported)
turt2live marked this conversation as resolved.
Show resolved Hide resolved

Other potential formats include videos and other image types - servers can support additional types
at their discretion.

If media cannot be animated, a static thumbnail should be returned instead. For example, if the client
requests `?animated=true` on a JPEG the server should not error but instead just return the downsized
JPEG as though the request was `?animated=false`.

When thumbnailing, servers SHOULD return one of the following types:
turt2live marked this conversation as resolved.
Show resolved Hide resolved
* `image/jpeg` (or `image/jpg`)
* `image/png` (non-animated)
turt2live marked this conversation as resolved.
Show resolved Hide resolved
* `image/gif` (animated)

The server's discretion about which one to use is trusted here. Servers can return alternative formats,
however currently it is strongly recommended that servers do not deviate from the set described here.

The default for `animated` is intentionally left undefined due to a variety of use cases within the
ecosystem which could demand that either `true` or `false` be preferred. Instead of picking a value,
servers SHOULD NOT animate thumbnails by default, but are not required to respect this condition. An
example use case would be a chat platform which is based on Matrix advertising the feature and wanting
to use pre-existing clients. They could go around and fork all the Matrix clients out there, or they
could have their server return a GIFs for everything.

## Potential issues

Server load could increase when the server tries to thumbnail a large file. Servers are expected to
mitigate this on their own, such as by providing an option to disable the feature or limiting how/when
they will animate the media.

## Alternatives

None that have presented themselves as reasonable.

## Security considerations

As mentioned, servers could face resource issues if this feature is left unchecked.

## Unstable prefix

While this MSC is not in a released version of the spec, implementations should use `org.matrix.msc2705`
as a prefix. For example, `?org.matrix.msc2705.animated=true`. No unstable endpoints are required due
to backwards compatibility.

## Implementations

This MSC is already implemented by matrix-media-repo.