用户:
a一只打工鸡查看:0 回复:1 评论:0 创建时间:2021-12-12T22:24:37



from PIL import Image
import wordcloud
import numpy
txt = 'Happy Birthday'
i = Image.open('cake.png')
i2 = Image.open('rainbow.png')
img = numpy.array(i)
img2 = numpy.array(i2)
c = wordcloud.ImageColorGenerator(img2)
wc = wordcloud.WordCloud(
background_color='grey',
repeat=True,
max_words=100,
mask=img,
contour_width=3,
contour_color='aqua',
color_func=c
)
wc.generate(txt)
wc.to_file('生日快乐.png')
p = Image.open('生日快乐.png')
p.show()