Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何在多个文件夹中的图像文件的文件名中插入文本_Python 3.x_Image_Save_Python Imaging Library - Fatal编程技术网

Python 3.x 如何在多个文件夹中的图像文件的文件名中插入文本

Python 3.x 如何在多个文件夹中的图像文件的文件名中插入文本,python-3.x,image,save,python-imaging-library,Python 3.x,Image,Save,Python Imaging Library,例如 ./test/test1/A1.jpg、A2.jpg、A3.jpg /test/test2/B1.jpg、B2.jpg、B3.jpg、 如何将文本插入多个文件夹中图像文件的文件名本身 我想用他们原来的名字保存他们。 下面的代码已失败 for image in images: with open(image,"rb") as file: img = Image.open(file) #imgResult = img.resize((400,400), re

例如

./test/test1/A1.jpg、A2.jpg、A3.jpg

/test/test2/B1.jpg、B2.jpg、B3.jpg、

如何将文本插入多个文件夹中图像文件的文件名本身 我想用他们原来的名字保存他们。 下面的代码已失败

for image in images:
with open(image,"rb") as file:
    img = Image.open(file)
    #imgResult = img.resize((400,400), resample = Image.BILINEAR)
    font_type = ImageFont.truetype('C:/Bitnami/wampstack-7.4.9-0/apache2/htdocs/hassle.ttf',100)
    draw = ImageDraw.Draw(img)
    draw.text(xy=(80,400),text="Text One", fill=(255,255,255), font=font_type)

    img.save(name)