admin管理员组文章数量:1394099
Our app takes canvas content and then display it as thumbnail with max-height of 150px
canvas can be as large as the monitor, for now lets pick 2560x1440
If converting to webp,
is there an equation to get quality number that roughly preserve image quality ? , maybe
targetHeight = 150
originalHeight = 1440
quality = targetHeight / originalHeight
// 150px / 1440px ~ 0.1 ?
canvas.toBlob((blob) => {
const currentScreenshot = URL.createObjectURL(blob);
}, "image/webp", quality);
Our app takes canvas content and then display it as thumbnail with max-height of 150px
canvas can be as large as the monitor, for now lets pick 2560x1440
If converting to webp,
is there an equation to get quality number that roughly preserve image quality ? , maybe
targetHeight = 150
originalHeight = 1440
quality = targetHeight / originalHeight
// 150px / 1440px ~ 0.1 ?
canvas.toBlob((blob) => {
const currentScreenshot = URL.createObjectURL(blob);
}, "image/webp", quality);
Share
Improve this question
edited Sep 11, 2019 at 4:11
Lydon Ch
asked Sep 11, 2019 at 4:05
Lydon ChLydon Ch
8,81520 gold badges80 silver badges136 bronze badges
1 Answer
Reset to default 5You can only set quality
value by defining mime type with image/jpeg
or image/webp
.
The default values are 0.92 & 0.80 respectively. Other values are ignored.
Please refer to this MDN link for HTMLCanvasElement.toBlob()
details.
本文标签: javascriptCanvas toBlob qualityStack Overflow
版权声明:本文标题:javascript - Canvas toBlob quality - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744731399a2622070.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论