微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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…

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。