Get image width and height using Javascript and jQuery

There can be situations in which you may need to validate(check) the dimensions(width or height) of an image before uploading on the server, or maybe you need to crop the image after checking its dimensions, in that case, you can do it at client-side using javascript, so in this article, I will show you how you can get width and height of an image using javascript.

Validating or checking dimensions of an image is much similar using jQuery, we can call a function to check dimensions on image change, create a new Image source and check it's dimensions using jQuery .width and .height functions