调整图片尺寸
from PIL import Imagefrom PIL import ImageEnhance
targetImg = fmImg(srcimgpath, width, height)targetImg.save(targetimgpath, "JPEG")
def fmImg(imgPath,picwidth,picheight): targetImg = Image.open(imgPath) targetImg = transformpic(targetImg) targetImg = targetImg.resize((picwidth, picheight), Image.ANTIALIAS) return targetImg
def transformpic(img): enc2 = ImageEnhance.Contrast(img) img = enc2.enhance(1.3) enc = ImageEnhance.Sharpness(img) img = enc.enhance(1.3) return img
翻转照片
srcimg = Image.open(srcimgpath)angle = 90targetImg = srcimg.rotate(angle)targetImg.save(targetimgpath, "JPEG")
时间: 2024-08-04 19:48:34