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

Missing overview of image size/resolution - intrinsic size #6835

Open
hamishwillee opened this issue Jul 13, 2021 · 0 comments
Open

Missing overview of image size/resolution - intrinsic size #6835

hamishwillee opened this issue Jul 13, 2021 · 0 comments
Labels
Content:Media Media docs document not written Missing document page help wanted If you know something about this topic, we would love your help!

Comments

@hamishwillee
Copy link
Collaborator

hamishwillee commented Jul 13, 2021

MDN does not (IMO) properly/well define the meaning of the various terms used around image properties: like intrinsic size, natural size, density adjusted size, pixels, device pixels, CSS pixels, device pixel density, resolution.

It would be good to have an explainer that shows the difference/relationships between all of these, where it is set, what assumptions are made by browsers. This then needs to be tied into the CSS and HTML docs, and also the Client-Hints HTTP header docs to make it clear where the information is set and how it can be used.

We would also check that there were good cross linked glossary entries: https://developer.mozilla.org/en-US/docs/Glossary/Intrinsic_Size, and I suspect we should also update some information in srcset and img tag on where the sizing comes from.

This follows on from #6798 (comment)

Resources:

A few notes:

  • Pixel - a small area of illumination on a display screen, one of many from which an image is composed. A picture element.
  • Pixel is also referred to as a device pixel or physical pixel.
  • Pixels do not have a fixed size. Their size is relative to the screen's resolution.
  • Logical pixel is simply the value of point in a grid, with no inherent physical size. So you might map that grid to a device for display on a device pixel.
    • I think the "resolution" is a measure of how many pixels that the screen can display. ie. a 640 by 480 resolution screen has that many
  • A screen also has a density, measured in ppi (pixels per inch). A screen with high density should display the same image smaller, because the pixels are closer together.
  • CSS pixel - The CSS spec defines a pixel as a unit of physical measurement. 1 pixel = 1/96th of an inch.
  • Device pixel ratio (DPR) - relationship between device pixels and CSS pixels for a particular device. A 192 ppi device has a devicePixelRatio of 2 (192 ppi/96 ppi = 2) because "2 of its display pixels are the size of 1 CSS pixel".
  • So the CSS pixel effectively defines the standard pixel and the standard resolution, and often screens are declared as a multiplier of this.
  • If an image measures 600 pixels by 300 pixels, then it will display at approximately 6" by 3" on a screen with 96 ppi resolution with no sizing applied.
  • Intrinsic size is the display size of an image if no CSS were applied to it (or so it says in the spec). But it isn't clear how this relates to CSS pixels. Kind of need to start with an image, double size image (same resolution), same size image (double density) and make clear what is actually meant in each case.
  • I THINK that basically a raster image is just a grid of logical pixels, that also may store some information about orientation, size of the pixels in each dimension, expected density (for printing?). A browser gets this image and just decides the intrinsic size from the pixels in each direction. If there is exif that might tell you the size is different, in which case it can infer the expected density of the pixels. All very confusing though.
  • When you set the size of an image in HTML (say) you're specifying the amount of space to reserve for layout. The actual image sent from server is the same so don't assume you're resizing the image on the server. i.e. hint to people not to get lazy and just use the width etc for shrinking (as I often do :-0 ).
@hamishwillee hamishwillee added needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. ContentWork: Extra labels Jul 13, 2021
@sideshowbarker sideshowbarker added document not written Missing document page needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. Opportunity assessment and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Jan 4, 2022
@Josh-Cena Josh-Cena added the Content:Media Media docs label Jun 27, 2023
@Josh-Cena Josh-Cena added help wanted If you know something about this topic, we would love your help! and removed opportunity assessment labels Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:Media Media docs document not written Missing document page help wanted If you know something about this topic, we would love your help!
Projects
None yet
Development

No branches or pull requests

3 participants