猫史档案馆


词 云 图

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


center_imagecenter_imagecenter_image

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()


回复

上一页1 页 / 共 1下一页
一缕余晖一缕余晖

sofa~~~

点赞0


评论