0

I'm uploading Image ,before uploading I need to check the image resolution whether it is greater than 920*675 resolution,should not allow images to upload less than the resolution(920*675)

Harry
  • 5
  • 1
  • 6

1 Answers1

0
var reader = new FileReader();
reader.onload = onLoadFile;
reader.readAsDataURL(filtItem._file);
          
function onLoadFile(event) {
    var img = new Image();
    img.src = event.target.result;
    console.log(img.width, img.height)
}

This is the code snippet copied from https://github.com/nervgh/angular-file-upload/blob/master/examples/image-preview/directives.js.

This is now part of the HTML5 File API, so in short you can use:

const i = new Image(); 
i.onload = () => console.log( i.width+", "+i.height );
i.src = imageData; 

See also:

Alicia Sykes
  • 5,997
  • 7
  • 36
  • 64