From 578f6133cd441a5354702fc8b14c5f9cebae12dc Mon Sep 17 00:00:00 2001 From: Rachit-Singh Date: Fri, 30 Apr 2021 09:47:37 +0530 Subject: [PATCH] Adding a display_image argument to show the image after the cloud creation --- stylecloud/stylecloud.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stylecloud/stylecloud.py b/stylecloud/stylecloud.py index 1c91e08..bffe86f 100644 --- a/stylecloud/stylecloud.py +++ b/stylecloud/stylecloud.py @@ -185,6 +185,7 @@ def gen_stylecloud( invert_mask: bool = False, pro_icon_path: str = None, pro_css_path: str = None, + display_image: bool = False, ): """Generates a stylecloud! :param text: Input text. Best used if calling the function directly. @@ -208,6 +209,7 @@ def gen_stylecloud( :param invert_mask: Whether to invert the icon mask. :param pro_icon_path: Path to Font Awesome Pro .ttf file if using FA Pro. :param pro_css_path: Path to Font Awesome Pro .css file if using FA Pro. + :param display_image: Whether to display image after creation or not. """ assert any([text, file_path]), "Either text or file_path must be specified." @@ -268,6 +270,10 @@ def pal_colors(word, font_size, position, orientation, random_state, **kwargs): wc.recolor(color_func=pal_colors, random_state=random_state) wc.to_file(output_name) + # display the image if this param is set to True + if display_image : + Image.open(output_name).show() + def stylecloud_cli(**kwargs): """Entrypoint for the stylecloud CLI."""