如何计算图像是横向还是纵向 [英] how to Calculate whether an image is landscape or portrait

查看:78
本文介绍了如何计算图像是横向还是纵向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用jquery创建一个图片库.可以使用jquery计算图像是横向还是纵向吗?

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

感谢您的支持.

推荐答案

您可以简单比较图像的宽度和高度.

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.
}

这篇关于如何计算图像是横向还是纵向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆