Python 3.6.3
如何在不保存和反复加载图片的情况下执行以下操作,有没有办法在两种格式之间转换图像? (允许我只在开头加载一次图片并在结尾处保存一次。)
from PIL import Image
import cv2
import numpy as np
img = Image.open(r'C:\Users\Chris\Desktop\programs\pic.jpg')
#modify picture using PIL functions
img.save(r'C:\Users\Chris\Desktop\programs\pic.jpg')
img = cv2.imread("pic.jpg")
#modify picture using cv2 functions
cv2.imwrite("pic.jpg", img)
img = Image.open(r'C:\Users\Chris\Desktop\programs\pic.jpg')
#modify picture using PIL functions
img.save(r'C:\Users\Chris\Desktop\programs\pic.jpg)')