1.python 单个修改照片的像素
import cv2
from PIL import Image as ImagePIL
from PIL import Image
im = ImagePIL.open('1.jpg')
print(im)
print(type(im))
im = cv2.imread('1.jpg')
image = Image.fromarray(cv2.cvtColor(im,cv2.COLOR_BGR2RGB))
image.save('11.jpg',quality=95,dpi=(100.0,100.0)) #调整图像的分辨率
2.python 批量修改照片的大小
#批量修改
from PIL import Image
import glob ,os
img_path = glob.glob("相对路径/*.png")
path_save = "相对路径/"
for file in img_path:
name = os.path.join(path_save, file)
im = Image.open(file)
im.thumbnail((number1,number2))
print(im.format, im.size, im.mode)
im.save(name,'svg')