How to get image size in bytes using javascript

后端 未结 3 1258
终归单人心
终归单人心 2021-01-20 17:43

please tell me how to get image file size in bytes using javascript.

Thanks

3条回答
  •  粉色の甜心
    2021-01-20 18:06

    If javascript engine supports canvas elements you can try to use canvas element and getImageData to fetch the pixel data from your image. Then, depending on type of the image you could create the binary representation of this image.

    Here is info about canvas element and getImagedata api:

    http://www.whatwg.org/specs/web-apps/current-work/#dom-context-2d-getimagedata

提交回复
热议问题