What are the possible data types for canvas' toDataURL() function?

前端 未结 2 861
慢半拍i
慢半拍i 2021-02-12 11:57
canvas.toDataURL(type, encoderOptions);

MDN\'s description about the type parameter says the following:

type

2条回答
  •  抹茶落季
    2021-02-12 12:21

    Per the firefox source code, they seems to support:

    • png
    • jpeg
    • ico
    • bmp

    Chrome per the source code, should support:

    • webp
    • png
    • jpeg
    • bmp

    Internet explorer modern versions, should be alike to Firefox(crossing fingers).

    If I need to vote the "per today" available options, I will go with: PNG, JPEG, and BMP

    Quality influences options:

    • JPEG, quality percent, where 0 is 0%, 0.5 is 50% and 1 is 100%
    • BMP, BPP, bytes per pixel (thanks to @apsillers for pointing out)

提交回复
热议问题