diff --git a/2.py b/2.py new file mode 100644 index 0000000..41ebc6e --- /dev/null +++ b/2.py @@ -0,0 +1,8 @@ +from PIL import Image +import numpy as numpy + +img = Image.open("6x2.png") +print(img ) + +vale = np.array(img) +print(value) \ No newline at end of file diff --git a/my_cloud.py b/my_cloud.py index 36a7e1a..fd2ecef 100644 --- a/my_cloud.py +++ b/my_cloud.py @@ -1,8 +1,14 @@ import wordcloud +from PIL import Image +import numpy as numpy with open('python二级考试大纲.txt',encoding='uty-8') as f: text = f.read() +img = Image.open("bell.png") +data = numpy.array(img) +img_colors=wordcloud.ImageColorGenerator(data) w=wordcloud.wordCloud(background_color="white", - font_path='SimHei.ttf') + font_path='SimHei.ttf', + mask=data,color_func=img_colors) w.generate(text) w.to_file("mycloud.png") \ No newline at end of file