用PIL库(Pillow:【pip install pillow】)读取图片:
from PIL import Image
img = Image.open(img_path)
size = img.size
w = img.size[0]
h = img.size[1]
用OpenCV库读取图片:
import cv2
img = cv2.imread(img_path)
size = img.size
w = img.size[1]
h = img.size[0]
区别在于:两者的w和h的位置是不同的!!