|
@@ -56,6 +56,10 @@ def main():
|
|
|
help = "the path to the mask image")
|
|
|
parser.add_argument("-c", "--contour", type = int, default = 0,
|
|
|
help = "the width of contour if you want it")
|
|
|
+ parser.add_argument("-x", "--width", type = int, default = 400,
|
|
|
+ help = "the width of canvas")
|
|
|
+ parser.add_argument("-y", "--height", type = int, default = 200,
|
|
|
+ help = "the height of canvas")
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
if not args.jobs is None:
|
|
@@ -76,12 +80,16 @@ def main():
|
|
|
if not args.mask is None:
|
|
|
from PIL import Image
|
|
|
import numpy as np
|
|
|
- mask = np.array(Image.open(args.mask))
|
|
|
+ # the mask need to be scaled
|
|
|
+ img = Image.open(args.mask).resize((args.width, args.height))
|
|
|
+ mask = np.array(img)
|
|
|
|
|
|
wc = WordCloud(font_path = args.fontpath,
|
|
|
mask = mask,
|
|
|
contour_width = args.contour,
|
|
|
- contour_color = "steelblue").generate_from_frequencies(c)
|
|
|
+ contour_color = "steelblue",
|
|
|
+ width = args.width,
|
|
|
+ height = args.height).generate_from_frequencies(c)
|
|
|
wc.to_image().save(args.output)
|
|
|
|
|
|
if __name__ == "__main__":
|