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

Update needed for image-rendering? #1375

Open
Malvoz opened this issue Nov 20, 2020 · 4 comments
Open

Update needed for image-rendering? #1375

Malvoz opened this issue Nov 20, 2020 · 4 comments

Comments

@Malvoz
Copy link

Malvoz commented Nov 20, 2020

MDN image-rendering suggests the following fallback declarations:

.pixelated {
  -ms-interpolation-mode: nearest-neighbor;
  image-rendering: pixelated;
}

.crisp-edges {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

Currently autoprefixer is different in that:

  • crisp-edges is not prefixed with -webkit-optimize-contrast
  • pixelated is prefixed with -webkit-optimize-contrast

Related issue: #449.

@Malvoz
Copy link
Author

Malvoz commented Nov 20, 2020

cc @magsout, @simevidas, @mathiasbynens

@Malvoz
Copy link
Author

Malvoz commented Nov 20, 2020

I think https://bugs.chromium.org/p/chromium/issues/detail?id=903021 suggests indeed an update is needed, and also perhaps extend to support image-rendering: smooth prefixed with (deprecated) optimizeQuality.

@ai
Copy link
Member

ai commented Nov 20, 2020

I think we can do something reasonable with 'smooth' and 'high-quality', but not really 'crisp-edges'. The way '-webkit-optimize-contrast' is currently is via a bilinear filter... which is not really what's intended by 'crisp-edges' the way I read the spec.

Seems like -webkit-optimize-contrast is not 100% equal to crisp-edges or pixelated.

Do we really need to change these very old prefixes? Seems like modern browsers support unprefixed version.

@simevidas
Copy link
Contributor

Autoprefixer currently does what is most useful to websites.

The spec (example 19, figure 4) suggests that image-rendering: pixelated should fully preserve pixels.

Chrome and Safari support this, but Firefox (bug) and IE don’t.

/* input */
img {
    image-rendering: pixelated;
}

/* Autoprefixer output */
img {
    -ms-interpolation-mode: nearest-neighbor; /* needed for IE */
        image-rendering: -moz-crisp-edges; /* needed for Firefox */
        image-rendering: pixelated;
}

Test page: https://output.jsbin.com/jopexoy/quiet

Autoprefixer adds these two non-standard declarations to ensure that pixelated preserves pixels in all browsers.

@Malvoz Is there a difference between pixelated and crisp-edges in today’s browsers? Safari supports both values, but I haven’t yet tested its implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants