javascript - Canvas toBlob quality - Stack Overflow

Our app takes canvas content and then display it as thumbnail with max-height of 150pxcanvas can be as

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
Add a ment  | 

1 Answer 1

Reset to default 5

You 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744731400a4590489.html

相关推荐

  • javascript - Canvas toBlob quality - Stack Overflow

    Our app takes canvas content and then display it as thumbnail with max-height of 150pxcanvas can be as

    1天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信