如何使用javascript以字节为单位获取图像大小 [英] How to get image size in bytes using javascript

查看:98
本文介绍了如何使用javascript以字节为单位获取图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我如何使用javascript以字节为单位获取图像文件大小。

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

谢谢

推荐答案

如果javascript引擎支持canvas元素,你可以尝试使用canvas元素和getImageData来获取图像中的像素数据。然后,根据图像的类型,您可以创建此图像的二进制表示。

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.

以下是有关canvas元素和getImagedata api的信息:

Here is info about canvas element and getImagedata api:

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

这篇关于如何使用javascript以字节为单位获取图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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