读取图片宽高信息,打包大小最小的模块matplotlib

想要写个读取图片宽高的脚本,结果使用cv2和PIL,imageio模块在用pyinstaller打包后,大小都在300mb以上,气死了,
最终结果使用matplotlib 模块,打包结果为4.6mb,这才对嘛.

# coding:utf-8
 
import cv2
import imageio
from scipy import misc
from PIL import Image
from matplotlib import pyplot as plt
 
image_path = "./images/000011.jpg"
 
# 使用pillow读取图片,获取图片的宽和高
img_pillow = Image.open(image_path)
img_width = img_pillow.width  # 图片宽度
img_height = img_pillow.height  # 图片高度
print("width -> {}, height -> {}".format(img_width, img_height))
 
img_cv = cv2.imread(image_path)
img_imageio = imageio.imread(image_path)
img_scipy = misc.imread(image_path)
img_matplot = plt.imread(image_path)
 
print(img_cv.shape)
print(img_imageio.shape)
print(img_scipy.shape)
print(img_matplot.shape)

猜你喜欢

转载自blog.csdn.net/weixin_43134049/article/details/114323980
今日推荐