Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript get image width and height

var img = new Image();
img.onload = function() {
  alert(this.width + 'x' + this.height);
}
img.src = 'http://www.google.com/intl/en_ALL/images/logo.gif';
Comment

check image resolution in javascript

window.URL = window.URL || window.webkitURL;

$("form").submit( function( e ) {
    var form = this;
    e.preventDefault(); //Stop the submit for now
                                //Replace with your selector to find the file input in your form
    var fileInput = $(this).find("input[type=file]")[0],
        file = fileInput.files && fileInput.files[0];

    if( file ) {
        var img = new Image();

        img.src = window.URL.createObjectURL( file );

        img.onload = function() {
            var width = img.naturalWidth,
                height = img.naturalHeight;

            window.URL.revokeObjectURL( img.src );

            if( width == 400 && height == 300 ) {
                form.submit();
            }
            else {
                //fail
            }
        };
    }
    else { //No file was input or browser doesn't support client side reading
        form.submit();
    }

});
Comment

javascript get width of image

image.width
Comment

PREVIOUS NEXT
Code Example
Javascript :: join in mongodb 
Javascript :: load external javascript file angular component 
Javascript :: check checkbox by jquery 
Javascript :: javascript reload page without refresh 
Javascript :: react bootstrap font awesome icons 
Javascript :: how to link js and a html file in vscode 
Javascript :: jquery code to make click function 
Javascript :: angularjs onclick 
Javascript :: passportjs serializeuser 
Javascript :: create react expo 
Javascript :: dropzone csrf codeigniter 
Javascript :: process.env 
Javascript :: async useeffect 
Javascript :: react-native build debug apk 
Javascript :: check if a date is more than 18 years javascript 
Javascript :: web3 js get network 
Javascript :: axios fainally 
Javascript :: Extract the domain name from a URL 
Javascript :: How to test useEffect in react testing library 
Javascript :: filter through date in mongooes 
Javascript :: useroutematch 
Javascript :: how to align text inside react component 
Javascript :: javjquery is emptyobject 
Javascript :: dynamically added button onclick not working 
Javascript :: filter object js 
Javascript :: how to use js console log 
Javascript :: round to decimal javascript 
Javascript :: sort array of objects javascript by key value 
Javascript :: jquery load 
Javascript :: set localstorage value 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =