HTML5 Canvas.toDataURL的默认质量是多少? [英] What is the default quality for HTML5 Canvas.toDataURL?

查看:2418
本文介绍了HTML5 Canvas.toDataURL的默认质量是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据mozilla的说法,canvas.toDataURL(1,2)的第二个参数是:

According to mozilla, the second parameter for canvas.toDataURL(1,2) is:


如果请求的类型是image / jpeg或image / webp,然后第二个
参数,如果它在0.0和1.0之间,则被视为指示图像
quality;如果第二个参数是其他参数,则使用图像质量的默认值
。其他参数被忽略。

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.

但我无法找到告诉我实际默认值的任何地方。

But I can't find anywhere that tells me what the default value actually is.

推荐答案

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

According to the spec, it alludes to the default being browser dependant:


如果第二个参数是0.0到1.0(包括0.0和1.0)范围内的数字,则必须将其视为所需的质量级别。如果它不是数字或超出该范围,用户代理必须使用默认值,就好像参数已被省略一样。

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.

编辑根据一位用户 Firefox的默认值为0.92。

According to one user the default for Firefox is 0.92.


您可以将JPEG质量指定为toDataURL函数的第二个参数。 Firefox中的默认质量是0.92(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错误报告 Chrome使用相同的内容。

And according to this webkit bug report Chrome uses the same.


...为Skia位图添加基于libjpeg的图像编码器。默认编码质量
是92以匹配Mozilla ...

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

这篇关于HTML5 Canvas.toDataURL的默认质量是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆