问题
I need to perform the following task:
- download an image by a given URL
- 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