如何解决保存魔杖图像时为什么会得到多个文件?
我有以下代码:
def resizeImg(img,width,height):
outerImg = img(width=width,height=height,background=Color("WHITE"))
outerImg.units='pixelsperinch'
outerImg.resolution = (300,300)
outerImg.format = img.format.lower()
outerImg.composite_channel('undefined',img,'over',int((width - img.width) / 2),int((height - img.height) / 2))
return outerImg
for file in os.listdir():
if os.path.splitext(file)[1] in ('.tif','.jpeg','.jpg'):
with Image() as img:
fname = ntpath.basename(file).split('.')[0] # BC154360-ANG
img.read(filename=file)
img.units='pixelsperinch'
img.resolution = (300,300)
img.compression_quality = 99
img.format = 'jpg'
dim = max(img.width,img.height)
img.resize(height=dim,width=dim) # make image square
img.resize(height=1500,width=1500) # set image size to 1500x1500
img.units='pixelsperinch'
img.resolution = (72,72)
img.save(filename = jpg_location + fname + '.jpg') # .jpg
问题是,运行此文件时我会收到多个文件,它们都略有不同。似乎每个图像的处理方式都不同。像运行display(img)
时的结果一样,“-0”图像似乎是正确的。
有人可以解释这里发生了什么吗?也许是channel
函数中operator
和composite_channel
参数的结果?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。