-
Notifications
You must be signed in to change notification settings - Fork 387
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
MSC4030: Progressive image in Matrix #4030
Open
ru-ka
wants to merge
9
commits into
matrix-org:main
Choose a base branch
from
ru-ka:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+82
−0
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
22137ef
Add files via upload
ru-ka 77bbec5
Update proposals/MSC4030: reference to MSC4011 changed
ru-ka 9b76215
Readibility fixes
ru-ka 91e8444
Update MSC4030: additional clarifications
ru-ka d682df2
Fixing language errors
ru-ka f720306
typo fix
ru-ka 5f5d41e
Merge branch 'matrix-org:main' into main
ru-ka ff44080
Grammar corrections
ru-ka 055576e
Use of more appropriate terms
ru-ka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# MSC4030: Progressive Images in Matrix | ||
|
||
## Introduction | ||
|
||
Efficient image handling is essential for delivering a seamless user experience within a communication platform like Matrix. | ||
This proposal recognizes the potential of modern progressive image formats to enhance image management within Matrix. | ||
|
||
While this document will occasionally highlight JPEG XL (referred to as 'jxl') as a notable use case, it is important to note | ||
that the concepts discussed herein are applicable to both progressive and non-progressive image formats, | ||
including WebP2 and JPEG itself. | ||
|
||
## Clarifications | ||
|
||
In Matrix, there are two types of thumbnails: | ||
|
||
- **Server-side generated thumbnails** available at the `thumbnail/` endpoint. | ||
- **Event thumbnails**, uploaded by clients and referenced using a separate MXC. | ||
|
||
This distinction exists because server-side generated thumbnails cannot be served in encrypted rooms or for media types other than `m.image`. | ||
|
||
### Reasons behind these changes | ||
|
||
The Matrix specification currently does not take into account that clients may benefit from receiving content in formats | ||
that align with their capabilities. By introducing media negotiation mechanisms, Matrix can enhance the client experience | ||
by serving content in the most efficient way possible. | ||
|
||
See [Issue #453](https://github.com/matrix-org/matrix-spec/issues/453) for further details. | ||
|
||
## Encrypted Rooms | ||
|
||
Due to the inability to re-encode images server-side, it is necessary to maintain the existing structure and functionality of the current API. | ||
|
||
To enhance user experience, it would be ideal loosening the requirements for progressive images in `m.image` events | ||
by eliminating the need for an event thumbnail (`"thumbnail_file"` entry). This change reduces storage costs, | ||
as progressive images do not need thumbnails. For proper functionality, client implementations should support on-the-fly | ||
decoding and decryption of media during download. | ||
|
||
In summary, if an image is progressive, clients MAY NOT generate the `"thumbnail_file"` entry (and the associated resources) | ||
in `m.image` messages sent in encrypted rooms. | ||
|
||
## Unencrypted Rooms | ||
|
||
Since we can re-encode the image server-side it would be optimal to serve the image (`/download` endpoint) and the server-side thumbnails | ||
(`/thumbnail` endpoint) with the best format that align with the client capabilities. | ||
|
||
### Eliminating Unwanted Behavior | ||
|
||
Clients do not acknowledge that, in unencrypted rooms, server-side generated thumbnails are available for image resources. | ||
As a result, they unnecessarily generate client-side thumbnails, upload them to the server, and reference them in the `m.image` event, | ||
creating redundant and unnecessary resources. | ||
|
||
To fix this issue, clients SHOULD NOT generate the `"thumbnail_file"` entry (and the associated resources) in `m.image` messages | ||
sent in unencrypted rooms. | ||
|
||
### Supporting Different Formats | ||
|
||
As proposed in [MSC4011](https://github.com/matrix-org/matrix-spec-proposals/pull/4011), media negotiation MUST be performed | ||
using the [HTTP Content Negotiation mechanism](https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation). | ||
This mechanism allows the delivery of images in progressive or more modern formats to clients that support such features. | ||
|
||
If the `Accept` header field is unspecified, absent or list unsupported formats, the server MUST provide the image resource | ||
as `image/png` or `image/jpeg`. | ||
|
||
All progressive-capable formats MUST always provide the image as a progressive one, even if the image is uploaded | ||
as a non-progressive image in a progressive-capable format. When serving the content, the server MUST provide the image | ||
in the same format (and all others) as a progressive image. | ||
|
||
If the negotiation is successful and a different non-progressive format is chosen for the image, the server MAY compare | ||
the size between the image in the transcoded format and the image in the original format, if the image in the original format | ||
is smaller than the transcoded one and is supported by the client, the server could chose to send the image in | ||
the original format instead of the transcoded one. However, this behavior SHOULD NOT be implemented for progressive formats. | ||
|
||
Clients SHOULD NOT connect to the `/thumbnail` endpoint if the server can provide images in progressive formats, | ||
supported by the client, at the `/download` endpoint. | ||
|
||
*Enabling this feature allows the server to store images in more efficient formats such as JPEG XL, reducing storage costs. | ||
These images can be quickly served as JPEG for clients that do not support the jxl format. Additionally, | ||
JPEG XL can perform lossless conversion of PNG and JPEG, further reducing storage costs and bandwidth usage.* | ||
|
||
## Alternatives | ||
|
||
[MSC4011 - Thumbnail media negotiation](https://github.com/matrix-org/matrix-spec-proposals/blob/clokep/thumbnail-media-negotiation/proposals/4011-thumbnail-media-negotiation.md). |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This seems like an oversimplification. According to the specification on thumbnails, there is no guarantee that the server supports generating thumbnails, it is a SHOULD. There is also no guarantee on which formats the server will support generating thumbnails for, which is clearly outlined in the specification.