position, orientation, random_state=None, **kwargs): return "hsl(0, 0%%, %d%%)" % (80 + font_size / 3) mask = np.array(Image.open(mask_path)) image_color = ImageColorGenerator(mask) text = open(data_path).read() #word cloud settings wc = WordCloud(font_path=content_font_path) wc.max_words = 500 wc.background_color = "#FFFFFF" wc.min_font_size = 7 wc.scale = 5 wc.prefer_horizontal = 1 wc.mode = 'RGBA' wc.mask = mask #wc creation wc = wc.generate(text) default_colors = wc.to_array() wc.recolor(color_func=image_color, random_state=3) image = wc.to_image() #add border image_size = image.size new_size = tuple(map(operator.add, image.size, (200, 200)))