简体   繁体   中英

Get image size in pixels using opencv2-python

I need the width and height of the image in pixels using opencv2(python)

I tried using im.shape but I dont think it gives the output in pixel units.

I measured the pixel units using page ruler extension and somehow it doesnt match with im.shape output.

Can anyone please tell me the units of im.shape and how to convert it into pixels?

you could use Pillow library as following:

from PIL import Image

print(Image.open(args["image"]).size)

Hope it helps to someone!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM