HTML5 Canvas.toDataURL的默认质量是多少?

前端之家收集整理的这篇文章主要介绍了HTML5 Canvas.toDataURL的默认质量是多少?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
根据mozilla,canvas.toDataURL(1,2)的第二个参数是:

If the requested type is image/jpeg or image/webp,then the second
argument,if it is between 0.0 and 1.0,is treated as indicating image
quality; if the second argument is anything else,the default value
for image quality is used. Other arguments are ignored.

但我无法找到告诉我默认值实际是什么的任何地方.

解决方法

根据 spec,它暗示默认是依赖于浏览器:

The second argument,if it is a number in the range 0.0 to 1.0 inclusive,must be treated as the desired quality level. If it is not a number or is outside that range,the user agent must use its default value,as if the argument had been omitted.

编辑:根据one user,Firefox的默认值为0.92.

You can specify the JPEG quality as the second parameter to the toDataURL function. The default quality in Firefox is 0.92 (92%).

根据这个webkit bug report Chrome使用相同的.

…Adds a libjpeg-based image encoder for Skia bitmaps. Default encoding quality is 92 to match Mozilla…

猜你在找的HTML5相关文章