python 用matplotlib获取图片的大小

import time
import matplotlib.image as mping
def getPngSize(pngPath ="aa.png"):
    print("获取图片尺寸大小:"+ str(pngPath))
    try:
        lena = mping.imread(pngPath)
    except:
        time.sleep(0.5)
        print("读图出错,重读")
        getPngSize(pngPath)
    size = tuple(lena.shape)
    print(size)
    return size[1],size[0]




print(getPngSize())

猜你喜欢

转载自blog.csdn.net/caobin0825/article/details/80338216