def makeImage(text): anne_mask = np.array(Image.open(path.join( d, "<SILHOUETTE>.png"))) # color_silhouette.png wc = WordCloud(background_color="white", mask=anne_mask) # generate word cloud wc.generate_from_frequencies(text) image_colors = ImageColorGenerator(anne_mask) image_colors.default_color = [0.6, 0.6, 0.6] wc.recolor(None, image_colors) wc.to_file("output.png")