You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importioimportosimportstringfromosimportpathfromwordcloudimportWordCloud# get data directory (using getcwd() is needed to support running example in generated IPython notebook)d=path.dirname(__file__) if"__file__"inlocals() elseos.getcwd()
# It is important to use io.open to correctly load the file as UTF-8text=io.open(path.join(d, 'all.txt')).read()
# the regex used to detect words is a combination of normal words, ascii art, and emojis# 2+ consecutive letters (also include apostrophes), e.x It'snormal_word=r"(?:\w[\w']+)"# 2+ consecutive punctuations, e.x. :)ascii_art=r"(?:[{punctuation}][{punctuation}]+)".format(punctuation=string.punctuation)
# a single character that is not alpha_numeric or other ascii printableemoji=r"(?:[^\s])(?<![\w{ascii_printable}])".format(ascii_printable=string.printable)
regexp=r"{normal_word}|{ascii_art}|{emoji}".format(normal_word=normal_word, ascii_art=ascii_art,
emoji=emoji)
# Generate a word cloud imagefont_path=path.join(d, 'NotoColorEmoji.ttf')
wc=WordCloud(font_path=font_path, regexp=regexp).generate(text)
# store to filewc.to_file(path.join(d, "emoji.png"))
# Display the generated image:# the matplotlib way:importmatplotlib.pyplotaspltplt.imshow(wc)
plt.axis("off")
plt.show()
Expected Results
A word cloud with emoji's (and words).
Actual Results
The error OSError: invalid pixel size.
Specifically:
Hi,
facing the same issue, but i don't get the "try the svg export and see if that works."
Any help on using Noto-emoji with PIL without firing OSError: invalid pixel size ?
Thanks !
Description
I can't use the NotoColorEmoji font as the
font_path
in a WC instance.It errors with
OSError: invalid pixel size
.It is likely an issue with PIL: python-pillow/Pillow#3346
I've tried to fix it locally by changing the
ImageFont.truetype
call inword_cloud
but that didn't help.
Steps/Code to Reproduce
Just swapped out the ttf font from the emoji example.
Example (https://amueller.github.io/word_cloud/auto_examples/emoji.html):
Expected Results
A word cloud with emoji's (and words).
Actual Results
The error
OSError: invalid pixel size
.Specifically:
Versions
The text was updated successfully, but these errors were encountered: