开发者

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

开发者 https://www.devze.com 2023-02-22 00:18 出处:网络
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 fin开发者_Go百科ding the orientation.

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 fin开发者_Go百科ding the orientation.


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.


try this ....

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


What about:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号