ImageIO - 从加载的图像中获取图像宽度和高度

时间:2018-04-17 04:57:47

标签: python-2.7 numpy python-imageio

我需要使用imageio获取图像的宽度和高度,使用select user_id, month(date_time) as visit_month, (select month(date_time) from tbl_activity where user_id = t.user_id and month(date_time) > month(a.date_time) order by month(date_time) LIMIT 1) as lead -- This could be re-express via lead() function from tbl_activity a group by user_id, month(date_time); 将图像加载到imageio中,如何获得图像的高度和宽度,或者在另一个词中获得图像的分辨率?在documentation中,它提到它将返回numpy数组

示例:

imread

当我打印出来时,我相信它会返回一个颜色数组列表

>>> from imageio import imread
>>> image_date = imread('c:/myImage.png')

任何想法?提前谢谢。

1 个答案:

答案 0 :(得分:2)

image_date是一个numpy数组,因此您可以使用shape属性。例如:

$ file black.png
black.png: PNG image data, 700 x 450, 8-bit/color RGB, non-interlaced

所以black.png是宽度为700像素,高度为450像素的图像。 然后在Python中:

imageio.imread('black.png').shape

输出:

(450, 700, 3)