Skip to content

Commit 127dd7f

Browse files
committed
Test for drawing mask contour on a transparent background.
1 parent b58eae9 commit 127dd7f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/test_wordcloud.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from wordcloud import WordCloud, get_single_color_func, ImageColorGenerator
2+
import os
23
import numpy as np
34
from random import Random
45
from nose.tools import (assert_equal, assert_greater, assert_true, assert_false,
@@ -229,6 +230,18 @@ def test_mask_contour():
229230
assert_true(all(sm_array[100, 300] == [0, 0, 255]))
230231

231232

233+
def test_test_mask_contour_transparent():
234+
# test if mask contour can be drawn on a transparent background
235+
# https://github.com/amueller/word_cloud/pull/389
236+
examples_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'examples'))
237+
mask_file = os.path.join(examples_dir, 'alice_mask.png')
238+
mask = np.array(Image.open(mask_file))
239+
w = WordCloud(mode='RGBA', background_color=None, contour_color='blue', contour_width=2, mask=mask,
240+
max_words=50, width=800, height=800)
241+
w.generate(THIS)
242+
w.to_file(NamedTemporaryFile(suffix=".png").name)
243+
244+
232245
def test_single_color_func():
233246
# test single color function for different color formats
234247
random = Random(42)

0 commit comments

Comments
 (0)