Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to Calculate whether an image is landscape or portrait

I am creating an image gallery with jquery. Is there any possibilities to Calculate whether an image is landscape or portrait using jquery?

Thanks for your support.

like image 842
geovani075 Avatar asked Jun 03 '13 06:06

geovani075


Video Answer


1 Answers

You can simply compare width and height of the image.

var someImg = $("#someId");
if (someImg.width() > someImg.height()){
    //it's a landscape
} else if (someImg.width() < someImg.height()){
    //it's a portrait
} else {
    //image width and height are equal, therefore it is square.
}
like image 119
Martyn Avatar answered Sep 20 '22 00:09

Martyn