python:来自某个范围内的组的图像生成器
我是新来的。 我在网上找到了一个代码,我正在尝试修复一些问题。
我希望我的组使用/查看该组指定文件夹 (*.png) 内的所有文件,而不仅仅是我键入的这些文件。
组1 = [ r“D:/IM/1x/5_0.png”, r“D:/IM/1x/5_1.png”, r"D:/IM/1x/5_2.png"
第 2 组正在使用位于
D:/IM/2x/
的文件,该文件夹中的图片可能多 100 倍 (1x),我不想将每个单独的图片分开行
这是代码。非常感谢您的帮助。 如果没有意义,请询问。
from PIL import Image
group1 = [
r"D:/IM/1x/5_0.png",
r"D:/IM/1x/5_1.png",
r"D:/IM/1x/5_2.png",
r"D:/IM/1x/5_3.png",
r"D:/IM/1x/5_4.png",
]
group2 = [
r"D:/IM/2x/4_0.png",
r"D:/IM/2x/4_1.png",
r"D:/IM/2x/4_2.png"
]
group3 = [
r"D:/IM/3x/3_1.png"
]
counter = 1
def createImage(a,b,c, counter):
first = group1[a]
second = group2[b]
third = group3[c]
image01 = Image.open(first).convert("RGBA")
image02 = Image.open(second).convert("RGBA")
image03 = Image.open(third).convert("RGBA")
intermediate = Image.alpha_composite(image01, image02)
intermediate2 = Image.alpha_composite(intermediate, image03)
name = "D:/DONE/" + str(counter) + ".png"
intermediate2.save(name)
for a in range(10):
for b in range(3):
for c in range(1):
createImage(a,b,c, counter)
counter = counter + 1
I am new here.
I found a code online and I am trying to fix some things.
I want my groups to use/see all files inside designated folder (*.png) for that group , not only these I typed.
group1 = [
r"D:/IM/1x/5_0.png",
r"D:/IM/1x/5_1.png",
r"D:/IM/1x/5_2.png"
Group 2 is using files located
D:/IM/2x/
it can be 100x more pictures inside this folder(1x), I do not want to locate every single one as separate line
Here is the code. Thank you very much for any help.
If it does not make sense, please ask.
from PIL import Image
group1 = [
r"D:/IM/1x/5_0.png",
r"D:/IM/1x/5_1.png",
r"D:/IM/1x/5_2.png",
r"D:/IM/1x/5_3.png",
r"D:/IM/1x/5_4.png",
]
group2 = [
r"D:/IM/2x/4_0.png",
r"D:/IM/2x/4_1.png",
r"D:/IM/2x/4_2.png"
]
group3 = [
r"D:/IM/3x/3_1.png"
]
counter = 1
def createImage(a,b,c, counter):
first = group1[a]
second = group2[b]
third = group3[c]
image01 = Image.open(first).convert("RGBA")
image02 = Image.open(second).convert("RGBA")
image03 = Image.open(third).convert("RGBA")
intermediate = Image.alpha_composite(image01, image02)
intermediate2 = Image.alpha_composite(intermediate, image03)
name = "D:/DONE/" + str(counter) + ".png"
intermediate2.save(name)
for a in range(10):
for b in range(3):
for c in range(1):
createImage(a,b,c, counter)
counter = counter + 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论