-
Notifications
You must be signed in to change notification settings - Fork 383
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
MSC4230: Flag for animated images #4230
base: main
Are you sure you want to change the base?
Changes from all commits
2366c1f
f2d9f02
7a54973
694fe6d
5e16aa6
d0771f6
4078173
e550201
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# MSC4230: 'Animated' flag for images | ||
|
||
Since animated images are thumbnailed to a still image, clients need to download the full | ||
image in order to display it animated. However, there is currently no way of telling that | ||
an image is animated without downloading the original image. This means that clients wishing | ||
to display the image as animated must download the original image for any image format which | ||
is capabale of being animated. This means they download the full size image for non-animated | ||
images even when the user never chooses to enlarge the image. | ||
|
||
Even clients that animate images on hover must pre-fetch the full size image if they want the | ||
animation to start without a delay while it's downloaded. | ||
|
||
## Proposal | ||
|
||
We add an optional boolean flag, `is_animated` to the `info` object of `m.image` events indicating if | ||
the image is animated or not. This SHOULD match whether the original image contains animation. Note | ||
that this will require clients probe the image file for animation. Simpler clients may, therefore, | ||
choose to not send this value at all, or always set it to false, meaning receiving clients are | ||
likely to render the image as non-animated. | ||
|
||
Example: | ||
|
||
```json5 | ||
{ | ||
"body": "partyparrot.gif", | ||
"file": { | ||
[...] | ||
}, | ||
"info": { | ||
"w": 640, | ||
"h": 480, | ||
"mimetype": "image/gif", | ||
"size": 35295, | ||
"is_animated": true, | ||
} | ||
``` | ||
|
||
If this flag is `false`, receiving clients can assume that the image is not animated. If `true`, they should | ||
assume that it is. | ||
|
||
Behaviour when the field is omitted is left up to the client. They might choose to behave as if it is present | ||
and set to `true`, ensuring backwards compatibility whilst still saving bandwidth for images where the flag | ||
is present and set to `false`. Perhaps they might decide to change this behaviour once more clients start | ||
sending the flag. | ||
|
||
## Potential issues | ||
|
||
Clients may lie about the flag which would cause unexpected behaviour, for example, an image which | ||
was not presented might then animate when the user clicks to enlarge it, allowing for 'jump scares' | ||
or similar. Clients may wish to prevent images from being animated if the flag is set to false. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't be sensible for an implementation to use this flag only as a hint as to whether it should preload the original, and probe the media regardless of when it was downloaded to confirm the animation? I feel like this MSC is recommending a client behaviour that is a tad too "trusting". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They could do that if they saw a need to. I've tried to be specific though and call out a distinct case where clients might want to take care over. I don't think it's really the spec's job to enumerate every detail that clients might possibly mess up, although we can certainly give more hints if you think there's something else worth calling out. |
||
|
||
As above, supporting animated images becomes harder for sending clients because they must work out if | ||
an image is animated in order to set the flag. | ||
|
||
## Alternatives | ||
|
||
We could specify that clients behave as if the flag is set to true if it's absent. This would mean | ||
clients that didn't want to probe images on upload could omit the flag, at the expense of receiving | ||
clients needing to download the original to probe for animation. | ||
|
||
We could require that servers, or clients in the case of encrypted rooms, preserve animation on | ||
thumbnailing. This is quite a burden for clients and would make thumbnails larger. | ||
|
||
This could also potentially be extended to `m.sticker` events. | ||
|
||
## Security considerations | ||
|
||
Potential for clients to lie about the flag and cause unexpected animation is covered in 'Potential | ||
Problems'. | ||
|
||
## Unstable prefix | ||
|
||
Until stable, the flag will be `org.matrix.msc4230.is_animated`. | ||
|
||
## Dependencies | ||
|
||
None. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to bring it up, we could also give this flag a more general name
prefetch_original
to express "you might wanna prefetch this", and apply it optionally to any attachment type. A client might assume based on the attachment type, mime type, flag, and other metadata combinations, whether it wants to prefetch, e.g. to play an animated image/gif without delay. Then again I fail to come up with other reasons you might want to hints about prefetching attachments.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I'm more persuaded by the idea of giving information about the media rather than trying to second guess what the client might want to do.