标签:key src opencv name erp write port nbsp host
cv2下载链接:https://files.pythonhosted.org/packages/17/2f/d9cc975666db25dcc412b76f46510ece2bd921465a361336d441a8313dc6/opencv_python-3.4.3.18-cp36-cp36m-win_amd64.whl
#导入cv模块 import cv2 as cv2 #读取图像,支持 bmp、jpg、png、tiff 等常用格式 image = cv2.imread(‘./a.jpg‘) #读取图像大小 size=image.shape print(‘图像大小为‘,size) print(size[0]) #创建窗口并显示图像,设定图像大小 res=cv2.resize(image,(1000,2000),interpolation=cv2.INTER_CUBIC) #显示图像 cv2.imshow(‘iker‘,res) #保存图像 cv2.imwrite("./cat3.jpg", res, [int(cv2.IMWRITE_JPEG_QUALITY), 100]) cv2.waitKey(0) #释放窗口 cv2.destroyAllWindows()
#导入cv模块 import cv2 as cv2 #读取图像,支持 bmp、jpg、png、tiff 等常用格式 def size(jpg,now_size): image = cv2.imread(jpg) # 读取图像大小 size = image.shape print(‘图像大小为‘, size) # 创建窗口并显示图像,设定图像大小 if size[0]>now_size: beishu=size[0]/now_size res=cv2.resize(image,(now_size,int(size[1]/beishu)),interpolation=cv2.INTER_CUBIC) #显示图像 # cv2.imshow(‘iker‘,res) #保存图像 cv2.imwrite("./cat3.jpg", res, [int(cv2.IMWRITE_JPEG_QUALITY), 100]) # cv2.waitKey(0) #释放窗口 # cv2.destroyAllWindows() else: print(‘图像不用缩小‘) def main(): now_size = 500 jpg=r‘./a.jpg‘ size(jpg, now_size) if __name__ == ‘__main__‘: main()
标签:key src opencv name erp write port nbsp host
原文地址:https://www.cnblogs.com/zhangdingqu/p/9782522.html