Contact emails
zm...@chromium.org, ju...@chromium.org
Spec
https://html.spec.whatwg.org/#imagesmoothingquality
Summary
Add support for the imageSmoothingQuality attribute on CanvasRenderingContext2D. It allows a web developer to choose the quality/performance tradeoff when scaling images. There are 3 options in total: low, medium and high.
Motivation
It gives developers more choices to handle multiple situations. Currently the developers only have 2 choices: on and off though the imageSmoothingEnabled attribute.
Compatibility Risk
It’s a brand new attribute. Given it’s just a render quality hint, the compatibility risk is very low.
Ongoing technical constraints
Skia implementation of MipMaps is broken on Chrome OS which prevent using ‘medium’ and ‘high’ quality. A solution will be either fix the issue or ignore this attribute on Chrome OS.
Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes.
OWP launch tracking bug
https://code.google.com/p/chromium/issues/detail?id=540761
Link to entry on the feature dashboard
https://www.chromestatus.com/features/4717415682277376
Requesting approval to ship?
Yes.
Demo link
Screenshot: (attached)
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
I like this feature.What is the feedback from other vendors and developers?
Ongoing technical constraints
Skia implementation of MipMaps is broken on Chrome OS which prevent using ‘medium’ and ‘high’ quality. A solution will be either fix the issue or ignore this attribute on Chrome OS.
LGTM3
I agree that this sounds good - I've got some implemention questions though.The spec defines 'low', 'medium' and 'high' for image smoothing, leaving it up to the UA to decide what those mean. As an aside, it bugs me a bit that we've got the barnacle of a boolean to switch smoothing on/off, and now a separate enum for quality. I'd prefer a single enum - off/low/medium/high. C'est la vie web.
What do they mean for Blink? For example, will low = bilinear, medium = bicubic and high = lanczos? Will they be the same for scaling up / down? Are they fixed or will we reserve the right to vary them depending on the power/abilities of the device?
From a performance perspective - developers who want to maximise performance at the cost of quality can already set imageSmoothingEnabled to false, and the spec mandates nearest neighbour interpolation. Implementing this will allow a developer to choose to use more cycles for high quality, so I don't really see it as removing a performance limitation.
This also sounds similar to https://drafts.csswg.org/css-images-3/#the-image-rendering - which applies to the whole canvas element. Implementation wise they aren't likely to intersect much?
The spec defines 'low', 'medium' and 'high' for image smoothing, leaving it up to the UA to decide what those mean. As an aside, it bugs me a bit that we've got the barnacle of a boolean to switch smoothing on/off, and now a separate enum for quality. I'd prefer a single enum - off/low/medium/high. C'est la vie web.When imageSmoothingEnabled is set to false, the filter we use is nearest neighbor. But we still need to retain the value of imageSmoothingQuiality attribute which becomes enabled when imageSmoothingEnabled is set to true again.
What do they mean for Blink? For example, will low = bilinear, medium = bicubic and high = lanczos? Will they be the same for scaling up / down? Are they fixed or will we reserve the right to vary them depending on the power/abilities of the device?Low means bilinear for both. Medium is mipmaps for down-scaling, bilinear for up-scaling. High means bicubic for up and mipmaps for down. Only the algorithm for off is fixed which is nearest neighbor.
From a performance perspective - developers who want to maximise performance at the cost of quality can already set imageSmoothingEnabled to false, and the spec mandates nearest neighbour interpolation. Implementing this will allow a developer to choose to use more cycles for high quality, so I don't really see it as removing a performance limitation.Setting imageSmoothingEnabled to false doesn't change the performance a lot especially on GPU which we get bilinear for free. Also, the developers sometimes just set imageSmoothingEnabled to false to get Retro style blocky pixel.
This also sounds similar to https://drafts.csswg.org/css-images-3/#the-image-rendering - which applies to the whole canvas element. Implementation wise they aren't likely to intersect much?No, drawing picture to canvas is a independent code process from drawing canvas to the page.
Thanks for the extra info.On 30 October 2015 at 01:40, Owen Min <zm...@google.com> wrote:The spec defines 'low', 'medium' and 'high' for image smoothing, leaving it up to the UA to decide what those mean. As an aside, it bugs me a bit that we've got the barnacle of a boolean to switch smoothing on/off, and now a separate enum for quality. I'd prefer a single enum - off/low/medium/high. C'est la vie web.When imageSmoothingEnabled is set to false, the filter we use is nearest neighbor. But we still need to retain the value of imageSmoothingQuiality attribute which becomes enabled when imageSmoothingEnabled is set to true again.But only because the spec requires you to :) I still think it's a barnacle, but not a big deal.
I share roc's doubts, and would not be surprised to see UA sniffing to pick the mode once testing reveals that one browser's "medium" is about as fast as another's "high". In the best case reverse engineering will sort it out, but it only takes one popular library making assumptions to lock all browsers into their initial, incompatible, interpretations.
On Fri, Oct 30, 2015 at 5:50 AM, Philip Jägenstedt <phi...@opera.com> wrote:I share roc's doubts, and would not be surprised to see UA sniffing to pick the mode once testing reveals that one browser's "medium" is about as fast as another's "high". In the best case reverse engineering will sort it out, but it only takes one popular library making assumptions to lock all browsers into their initial, incompatible, interpretations.The intent of ImageSmoothingQuality, is to provide a hint --just a hint-- as to whether the implementation should prioritize speed or visual quality. To be honest, I think we could have done without 'medium', but I don't mind it. For years we've been stuck beetween the requirements of game devs who want us to prioritize speed, and most other kinds of apps that want best image quality. Due to an obsession with benchmarks, we have been leaning more toward making game devs happy, to the detriment of others. In previous debates it was argued that filtering quality was a 'quality of implementation' issue that is up to browser implementors to figure out. That line of thought has led us to a situation where we had to make choices for the whole web, which will inevitably always make one group of devs unhappy. Trying to auto-detect whether an app should prefer quality over speed (as has been suggested in the past) is likely to be perceived by web developers as unpredictable idiosyncratic behavior. ImageSmoothingQuality is an answer to this problem. I share your concerns about this attribute being abused by by people who will over-analyze it, but I still think it does a lot more good than harm to the platform. Do you have a better idea?
ImageSmoothingEnabled, on the other hand, is a style choice that is loaded with editorial intent. This is why it passed the 'should this be added to the standard' litmus test with much less debate.The fact that one is a style choice and the other is a quality *hint* is a good reason to keep these two attributes separate IMHO.
On Fri, Oct 30, 2015 at 4:39 PM, Justin Novosad <ju...@chromium.org> wrote:On Fri, Oct 30, 2015 at 5:50 AM, Philip Jägenstedt <phi...@opera.com> wrote:I share roc's doubts, and would not be surprised to see UA sniffing to pick the mode once testing reveals that one browser's "medium" is about as fast as another's "high". In the best case reverse engineering will sort it out, but it only takes one popular library making assumptions to lock all browsers into their initial, incompatible, interpretations.The intent of ImageSmoothingQuality, is to provide a hint --just a hint-- as to whether the implementation should prioritize speed or visual quality. To be honest, I think we could have done without 'medium', but I don't mind it. For years we've been stuck beetween the requirements of game devs who want us to prioritize speed, and most other kinds of apps that want best image quality. Due to an obsession with benchmarks, we have been leaning more toward making game devs happy, to the detriment of others. In previous debates it was argued that filtering quality was a 'quality of implementation' issue that is up to browser implementors to figure out. That line of thought has led us to a situation where we had to make choices for the whole web, which will inevitably always make one group of devs unhappy. Trying to auto-detect whether an app should prefer quality over speed (as has been suggested in the past) is likely to be perceived by web developers as unpredictable idiosyncratic behavior. ImageSmoothingQuality is an answer to this problem. I share your concerns about this attribute being abused by by people who will over-analyze it, but I still think it does a lot more good than harm to the platform. Do you have a better idea?That imageSmoothingQuality is just a hint is precisely the source of the compatibility risk. If the underlying frameworks supported it, my idea would be an enum of concrete algorithms, like "nearest", "linear", "bilinear", "bicubic", etc., and a way to test which ones are actually supported. Unfortunately, that doesn't seem like a realistic hope, as per my previous email.So, unless a better idea comes along real soon now, I will support shipping this.
On Fri, Oct 30, 2015 at 3:14 PM, Philip Jägenstedt <phi...@opera.com> wrote:On Fri, Oct 30, 2015 at 4:39 PM, Justin Novosad <ju...@chromium.org> wrote:On Fri, Oct 30, 2015 at 5:50 AM, Philip Jägenstedt <phi...@opera.com> wrote:I share roc's doubts, and would not be surprised to see UA sniffing to pick the mode once testing reveals that one browser's "medium" is about as fast as another's "high". In the best case reverse engineering will sort it out, but it only takes one popular library making assumptions to lock all browsers into their initial, incompatible, interpretations.The intent of ImageSmoothingQuality, is to provide a hint --just a hint-- as to whether the implementation should prioritize speed or visual quality. To be honest, I think we could have done without 'medium', but I don't mind it. For years we've been stuck beetween the requirements of game devs who want us to prioritize speed, and most other kinds of apps that want best image quality. Due to an obsession with benchmarks, we have been leaning more toward making game devs happy, to the detriment of others. In previous debates it was argued that filtering quality was a 'quality of implementation' issue that is up to browser implementors to figure out. That line of thought has led us to a situation where we had to make choices for the whole web, which will inevitably always make one group of devs unhappy. Trying to auto-detect whether an app should prefer quality over speed (as has been suggested in the past) is likely to be perceived by web developers as unpredictable idiosyncratic behavior. ImageSmoothingQuality is an answer to this problem. I share your concerns about this attribute being abused by by people who will over-analyze it, but I still think it does a lot more good than harm to the platform. Do you have a better idea?That imageSmoothingQuality is just a hint is precisely the source of the compatibility risk. If the underlying frameworks supported it, my idea would be an enum of concrete algorithms, like "nearest", "linear", "bilinear", "bicubic", etc., and a way to test which ones are actually supported. Unfortunately, that doesn't seem like a realistic hope, as per my previous email.So, unless a better idea comes along real soon now, I will support shipping this.IMHO, the enum value names should perhaps reflect the intended use and be as non-explicit as possible, to reflect the fact that this is but a hint. Something like: {fastest, medium, nicest};
Philip