Commit ccdb542c authored by Raphael Boidol's avatar Raphael Boidol
Browse files

remove PIL deprecation warnings by using new API

parent bef83e5a
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment