Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
keeleliin
word_cloud_est
Commits
ccdb542c
Commit
ccdb542c
authored
Dec 05, 2015
by
Raphael Boidol
Browse files
remove PIL deprecation warnings by using new API
parent
bef83e5a
Changes
4
Hide whitespace changes
Inline
Side-by-side
examples/a_new_hope.py
View file @
ccdb542c
...
...
@@ -6,7 +6,7 @@ Using the recolor method and custom coloring functions.
"""
import
numpy
as
np
import
Image
from
PIL
import
Image
from
os
import
path
import
matplotlib.pyplot
as
plt
import
random
...
...
examples/colored.py
View file @
ccdb542c
...
...
@@ -11,7 +11,7 @@ but make sure the image shapes line up.
"""
from
os
import
path
import
Image
from
PIL
import
Image
import
numpy
as
np
import
matplotlib.pyplot
as
plt
...
...
examples/masked.py
View file @
ccdb542c
...
...
@@ -6,7 +6,7 @@ Using a mask you can generate wordclouds in arbitrary shapes.
"""
from
os
import
path
import
Image
from
PIL
import
Image
import
numpy
as
np
import
matplotlib.pyplot
as
plt
...
...
wordcloud/wordcloud.py
View file @
ccdb542c
...
...
@@ -289,9 +289,8 @@ class WordCloud(object):
orientation
=
Image
.
ROTATE_90
transposed_font
=
ImageFont
.
TransposedFont
(
font
,
orientation
=
orientation
)
draw
.
setfont
(
transposed_font
)
# get size of resulting text
box_size
=
draw
.
textsize
(
word
)
box_size
=
draw
.
textsize
(
word
,
font
=
transposed_font
)
# find possible places using integral image:
result
=
occupancy
.
sample_position
(
box_size
[
1
]
+
self
.
margin
,
box_size
[
0
]
+
self
.
margin
,
...
...
@@ -307,7 +306,7 @@ class WordCloud(object):
x
,
y
=
np
.
array
(
result
)
+
self
.
margin
//
2
# actually draw the text
draw
.
text
((
y
,
x
),
word
,
fill
=
"white"
)
draw
.
text
((
y
,
x
),
word
,
fill
=
"white"
,
font
=
transposed_font
)
positions
.
append
((
x
,
y
))
orientations
.
append
(
orientation
)
font_sizes
.
append
(
font_size
)
...
...
@@ -433,9 +432,8 @@ class WordCloud(object):
font
=
ImageFont
.
truetype
(
self
.
font_path
,
font_size
*
self
.
scale
)
transposed_font
=
ImageFont
.
TransposedFont
(
font
,
orientation
=
orientation
)
draw
.
setfont
(
transposed_font
)
pos
=
(
position
[
1
]
*
self
.
scale
,
position
[
0
]
*
self
.
scale
)
draw
.
text
(
pos
,
word
,
fill
=
color
)
draw
.
text
(
pos
,
word
,
fill
=
color
,
font
=
transposed_font
)
return
img
def
recolor
(
self
,
random_state
=
None
,
color_func
=
None
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment