Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can show image in proper orientation, Landscape or portrait

I am having a file input control on the page to select an image. When user selects an image, I am showing image on the page.

But my problem is, when user selects a vertical or portrait image it is displayed in landscape mode.

So, how can I detect image orientation & apply proper css to show in Landscape or Portrait view.

like image 309
Shankar Avatar asked Nov 10 '22 10:11

Shankar


1 Answers

Step #1:

Check if the image's width is bigger than its heigth. Then you'll figure out that the image is a landscape image. You can check it quickly using javascript.

Step #2:

Create a CSS and apply it using a class (apply the class using javascript) for whatever orientation you need.

like image 167
Rafael Cavalcante Avatar answered Nov 14 '22 22:11

Rafael Cavalcante