-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add image formats #27168
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
base: main
Are you sure you want to change the base?
Add image formats #27168
Conversation
Tip: Review these changes grouped by change (recommended for most PRs), or grouped by feature (for large PRs). |
5ccaaec
to
e1e70dd
Compare
Something I think is essential to landing this would be a documented (and very sharp) definition of what qualifies as support for these features. Though they implicate support for HTML, CSS, and web API features, the new top-level namespace implies a different scope. It'd be great to be explicit about what that scope is. (Automated tests could also serve as a definition of supported, but I don't know how practical that is.) |
|
||
- `formats/image` - Image formats | ||
|
||
An image format is considered supported if it displays correctly when used in an `<img>` element's `src` attribute, or as a CSS `background-image`. |
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.
@ddbeck What do you think about this?
PS: Would it be better to move /media/formats/image
to /media/image-formats
, to avoid the unnecessary nesting?
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.
I guess now I'm wondering what the media
name space would contain that is not a format? Seems like maybe the top-level key could be formats
or media-formats
, with images
as the next level. The only other thing we've discussed is video formats, right? So maybe the hypothetical future looks like this?
.
├── api
├── css
├── …
└── media-formats
├── images
│ ├── avif.json
│ ├── bmp.json
│ ├── gif.json
│ └── …
└── video-containers
├── 3gp.json
├── mov.json
├── mp4.json
├── ogg.json
└── …
Also note the pluralization there. Most everywhere else is plural (elements
, at-rules
, builtins
, etc.).
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.
Sorry, I didn't answer the original question.
An image format is considered supported if it displays correctly when used in an
<img>
element'ssrc
attribute, or as a CSSbackground-image
.
Some questions back to you:
-
"or" suggests that as long as it works in at least one of these, it qualifies as full support. What about something like
ico
, where the primary use case is neither of the two? Do we make an exception for that? -
"correctly" seems pretty imprecise. How wold you know if it were incorrect? Maybe it'd be better to frame this as a set of specific expected characteristics (e.g., no distorted colors, shows transparency if applicable, aspect ratio corresponding to the image data, etc.) that we could "test" (procedurally if not programmatically)?
This is a place where some user research or testing would be good—to find out what developers think of when a format is "supported."
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.
I guess now I'm wondering what the
media
name space would contain that is not a format?
Maybe media.images
would be a good compromise, as it avoids the terms codec
and format
altogether, and we can just use those terms where necessary in the individual feature's key and/or description.
- "or" suggests that as long as it works in at least one of these, it qualifies as full support.
Good point, agree.
- "correctly" seems pretty imprecise.
- frame this as a set of specific expected characteristics (e.g., no distorted colors, shows transparency if applicable, aspect ratio corresponding to the image data, etc.)
Agree that framing around expectation is better, so how about:
An image format is considered supported if it displays correctly when used in an `<img>` element's `src` attribute, or as a CSS `background-image`. | |
An image format is considered supported if it displays as expected (e.g., no distorted colors, shows transparency if applicable, aspect ratio corresponding to the image data, etc.) when used in an `<img>` element's `src` attribute, and when used as a CSS `background-image`. |
- This is a place where some user research or testing would be good—to find out what developers think of when a format is "supported."
I don't think user research or further testing is justified at this time.
If we receive feedback that the data is incomplete, incorrect, or misleading, we can refine. Most likely we can address feedback by adding subfeatures, either under the media format, or under the feature that the specific use case or expectation relates to (cf. HTMLCanvasElement: toBlob() method).
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.
@ddbeck Is the above an acceptable compromise?
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.
I don't think user research or further testing is justified at this time.
If we receive feedback that the data is incomplete, incorrect, or misleading, we can refine. Most likely we can address feedback by
I think this gets at the heart of the matter for me: it's easy to add things but harder to take them away. If we're wrong we might hear about it, but if we're irrelevant, then we might never get any feedback (and maintain data for no real purpose). Indifference is a failure mode I care about as much as being correct—and perhaps more, in this particular case, given the potential costs of maintaining a deep matrix of support information.
I'm not asking for something heavy-weight here, but I think we should be able to point at something (some blog posts or Stack Overflow questions or social media posts would be enough) that shows that the definition of supported we're choosing matters (to anyone beyond some completionist tech writers 😅).
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.
Maybe
media.images
would be a good compromise, as it avoids the termscodec
andformat
altogether, and we can just use those terms where necessary in the individual feature's key and/or description.
I guess I don't mind that structure, but I worry a little about vagueness. "Media" gets used in lots of places (media queries, media devices, media streams, etc.) and I think being specific in some way would make this easier to talk about and maintain, if nothing else.
We discussed this in today's BCD meeting, and agreed to (1) compare the data with caniuse to spot any important omissions, and to also (2) ask @Fyrd if and how he would merge this data into the existing caniuse data for image formats. |
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.
Compared the data with Can I use.
"version_added": "23" | ||
}, | ||
{ | ||
"version_added": "17", |
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.
According to https://caniuse.com/webp, Chrome 9 added WebP support, but I couldn't confirm this with my own tests. It was possibly only behind a flag.
Summary
Introduces the
media
top level directory, and adds image formats undermedia.formats.image
.Test results and supporting details
Sources:
Related issues
Part of #6971.