user576914
user576914

Reputation: 199

How to find if image in landscape or portrait orientation in Java?

Is there any method that shows if the image is in landscape orientation or not?
I have a file and I create a BufferedImage, but don't know what's the method for finding the orientation.

Upvotes: 1

Views: 4171

Answers (3)

HASNEN LAXMIDHAR
HASNEN LAXMIDHAR

Reputation: 72

try this ....

  if (image.getIconWidth() > image.getIconHeight()) 
    {  result = 0;
     } else {
    result = 1;
    }

Upvotes: 0

Koziołek
Koziołek

Reputation: 2874

There are not method but the easiest way:

public boolean isLandscape(BufferedImage image){
  return image.getWidth() > image.getHeight();
}

You could put this method to some Utils class.

Upvotes: 2

user unknown
user unknown

Reputation: 36259

What about:

return (bi.getHeight () < bi.getWidth ());

Upvotes: -1

Related Questions