dojo: download image and detect pixel size

ε祈祈猫儿з 提交于 2019-12-13 04:29:33

问题


I need to perform the following task:

  1. download an image by a given URL
  2. detect the size of that image in pixels or in kb, whatever is easier

Does anybody know a good approach with dojo or with "plain JavaScript"?


回答1:


Is this simple approach sufficient? I'm not sure if you meant "download" to mean "save to the client's computer" or simply "retrieve from the remote server".

<script type="text/javascript">
    var image = new Image();
    image.onload = function() {
        alert("Width: " + image.width + ", Height: " + image.height);
    }
    image.src = "http://placehold.it/350x150";
</script>


来源:https://stackoverflow.com/questions/18018089/dojo-download-image-and-detect-pixel-size

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!