官方qq群:591191475
快手群:K225545989167
官方qq号:258167139
- 点击链接加入群聊【IT交流Java,Python,云计算,大数据
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')