0

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 Answers1

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>
Lucas
  • 8,035
  • 2
  • 32
  • 45