[英]How do you save images with a different name and varying numbers after editing in python pillow module
We were tasked to figure out what was wrong with a code concerning batch image processing.我们的任务是找出有关批量图像处理的代码有什么问题。 And the saving part got me confused...
保存部分让我感到困惑......
enhancedImg = ImageEnhance.Contrast(image)
enhancedImg.enhance(.8).save("photo-" + count + "-edited.jpg")
if count = imageFiles.length
break
else:
count++
What do you think is wrong with this?你认为这有什么问题?
your code is kind to unclear to me tried to grasp its aim and reproduce it somehow.你的代码对我来说有点不清楚,试图掌握它的目标并以某种方式重现它。
given input image:给定输入图像:
I have:我有:
from PIL import Image, ImageEnhance,ImageDraw,ImageFont
image = Image.open('image-2.jpg')
enhancer = ImageEnhance.Sharpness(image)
enance = []
for i in range(100):
factor = i / 4.0
enance.append(factor)
# print(enance)
for j in enance:
img = enhancer.enhance(j)
img_draw = ImageDraw.Draw(img)
font = ImageFont.truetype("/usr/share/fonts/truetype/freefont/Ubuntu-C.ttf", 100)
img_draw.text((70, 250), f"Sharpness {j:f}", font = font, fill='red')
img.show()
img.save("photo-" + str(j) + "-edited.jpg")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.