diff --git a/Quote2Image.egg-info/PKG-INFO b/Quote2Image.egg-info/PKG-INFO index ed5ba3d..f5e5890 100644 --- a/Quote2Image.egg-info/PKG-INFO +++ b/Quote2Image.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: Quote2Image -Version: 0.0.4 +Version: 0.0.5 Summary: A python module to convert text quotes into graphical images Home-page: https://github.com/NotCookey/Quote2Image Author: NotCookey @@ -26,18 +26,23 @@ pip install Quote2Image ``` ## Usage -**The convert function takes the following arguments:** +**The `Convert` function takes the following arguments:** - **`quote` : The quote to convert.** - **`author` : The author of the quote.** - **`fg` : The foreground color of the text.** - **`bg` : The background color of the image.** - **`font_type` : The font to use for the text.** -- **`font_size` : The font size to use for the text.** +- **`font_size` : This font size is used for the quote and watermark.** +- **`font_size_author` : This font size is used for the author (Optional, Default value is set to `font_size`).** - **`width` : The width of the image.** - **`height` : The height of the image.** +- **`watermark_text` : The text for the watermark (Leave it blank for no watermarks).** +- **`watermark_font_size` : The font size for the watermark text (Optional, Default save is set to `font_size`).** -**Generating an image using RGB background and foreground, The package comes with a builtin `GenerateColors` function that generates a fg and bg color with the correct amount of luminosity and returns them in tuples.** +## Generating an image using RGB background and foreground + +**The package comes with a builtin `GenerateColors` function that generates a fg and bg color with the correct amount of luminosity and returns them in tuples.** ```python from Quote2Image import Convert, GenerateColors @@ -58,7 +63,9 @@ img=Convert( # Save The Image as a Png file img.save("hello.png") ``` -**Generating an image using a custom background image. We can do that using the `ImgObject` that gives us alot of flexibility on how we want our background Image to be.** +## Generating an image using a custom background image. + + **We can do that using the `ImgObject` that gives us alot of flexibility on how we want our background Image to be.** **The `ImgObject` class takes the following arguments:** @@ -87,6 +94,35 @@ img=Convert( img.save("hello.png") ``` +## Adding a watermark: + +- **`watermark_text` : The text for the watermark.** +- **`watermark_font_size` : The font size for the watermark text.** + +```py +from Quote2Image import Convert, GenerateColors + +# Generate Fg and Bg Color +fg, bg = GenerateColors() + +img=Convert( + quote="Pooing keeps you healthy", + author="Pee", + fg=fg, + bg=bg, + font_size=32, + font_type="arial.ttf", + font_size_author=25, + width=1080, + height=450, + watermark_text="@My.Watermark", + watermark_font_size=15 +) + +# Save The Image as a Png file +img.save("hello.png") +``` + ## Permissions - **You are allowed to use, modify, and distribute the module.** diff --git a/Quote2Image/Quote2Image.py b/Quote2Image/Quote2Image.py index 4381ad9..917329a 100644 --- a/Quote2Image/Quote2Image.py +++ b/Quote2Image/Quote2Image.py @@ -35,7 +35,7 @@ def GenerateColors(): return foreground_color, background_color -def Convert(quote, author, fg, bg, font_type, font_size, width, height): +def Convert(quote, author, fg, bg, font_type, font_size, width, height, watermark_text, watermark_font_size:int=None, font_size_author:int=None): if isinstance(bg, ImgObject): image = Image.open(bg.image).resize((width, height)) enhancer = ImageEnhance.Brightness(image) @@ -47,7 +47,11 @@ def Convert(quote, author, fg, bg, font_type, font_size, width, height): draw = ImageDraw.Draw(image) + if font_size_author is None: + font_size_author = font_size + font = ImageFont.truetype(font_type, font_size) + font_author = ImageFont.truetype(font_type, font_size_author) lines = [] line = "" @@ -75,8 +79,17 @@ def Convert(quote, author, fg, bg, font_type, font_size, width, height): draw.text((x, y), " - ", fg, font=font) y += font_size // 2 - author_width = draw.textsize(author, font)[0] + author_width = draw.textsize(author, font_author)[0] x = (width - author_width) // 2 - draw.text((x, y+15), author, fg, font=font) + draw.text((x, y+15), author, fg, font=font_author) + + if watermark_text: + if watermark_font_size is None: + watermark_font_size = font_size + watermark_font = ImageFont.truetype(font_type, watermark_font_size) + watermark_width, watermark_height = draw.textsize(watermark_text, watermark_font) + x = width - watermark_width - 10 + y = height - watermark_height - 10 + draw.text((x, y), watermark_text, fg, font=watermark_font) return image diff --git a/Quote2Image/__init__.py b/Quote2Image/__init__.py index d9543fc..00e62df 100644 --- a/Quote2Image/__init__.py +++ b/Quote2Image/__init__.py @@ -1,3 +1,3 @@ from .Quote2Image import ImgObject from .Quote2Image import GenerateColors -from .Quote2Image import Convert \ No newline at end of file +from .Quote2Image import Convert diff --git a/README.md b/README.md index 12d9efd..0ffb91f 100644 --- a/README.md +++ b/README.md @@ -9,18 +9,23 @@ pip install Quote2Image ``` ## Usage -**The convert function takes the following arguments:** +**The `Convert` function takes the following arguments:** - **`quote` : The quote to convert.** - **`author` : The author of the quote.** - **`fg` : The foreground color of the text.** - **`bg` : The background color of the image.** - **`font_type` : The font to use for the text.** -- **`font_size` : The font size to use for the text.** +- **`font_size` : This font size is used for the quote and watermark.** +- **`font_size_author` : This font size is used for the author (Optional, Default value is set to `font_size`).** - **`width` : The width of the image.** - **`height` : The height of the image.** +- **`watermark_text` : The text for the watermark (Leave it blank for no watermarks).** +- **`watermark_font_size` : The font size for the watermark text (Optional, Default save is set to `font_size`).** -**Generating an image using RGB background and foreground, The package comes with a builtin `GenerateColors` function that generates a fg and bg color with the correct amount of luminosity and returns them in tuples.** +## Generating an image using RGB background and foreground + +**The package comes with a builtin `GenerateColors` function that generates a fg and bg color with the correct amount of luminosity and returns them in tuples.** ```python from Quote2Image import Convert, GenerateColors @@ -41,7 +46,9 @@ img=Convert( # Save The Image as a Png file img.save("hello.png") ``` -**Generating an image using a custom background image. We can do that using the `ImgObject` that gives us alot of flexibility on how we want our background Image to be.** +## Generating an image using a custom background image. + + **We can do that using the `ImgObject` that gives us alot of flexibility on how we want our background Image to be.** **The `ImgObject` class takes the following arguments:** @@ -70,6 +77,35 @@ img=Convert( img.save("hello.png") ``` +## Adding a watermark: + +- **`watermark_text` : The text for the watermark.** +- **`watermark_font_size` : The font size for the watermark text.** + +```py +from Quote2Image import Convert, GenerateColors + +# Generate Fg and Bg Color +fg, bg = GenerateColors() + +img=Convert( + quote="Pooing keeps you healthy", + author="Pee", + fg=fg, + bg=bg, + font_size=32, + font_type="arial.ttf", + font_size_author=25, + width=1080, + height=450, + watermark_text="@My.Watermark", + watermark_font_size=15 +) + +# Save The Image as a Png file +img.save("hello.png") +``` + ## Permissions - **You are allowed to use, modify, and distribute the module.** diff --git a/build/lib/Quote2Image/Quote2Image.py b/build/lib/Quote2Image/Quote2Image.py index 4381ad9..917329a 100644 --- a/build/lib/Quote2Image/Quote2Image.py +++ b/build/lib/Quote2Image/Quote2Image.py @@ -35,7 +35,7 @@ def GenerateColors(): return foreground_color, background_color -def Convert(quote, author, fg, bg, font_type, font_size, width, height): +def Convert(quote, author, fg, bg, font_type, font_size, width, height, watermark_text, watermark_font_size:int=None, font_size_author:int=None): if isinstance(bg, ImgObject): image = Image.open(bg.image).resize((width, height)) enhancer = ImageEnhance.Brightness(image) @@ -47,7 +47,11 @@ def Convert(quote, author, fg, bg, font_type, font_size, width, height): draw = ImageDraw.Draw(image) + if font_size_author is None: + font_size_author = font_size + font = ImageFont.truetype(font_type, font_size) + font_author = ImageFont.truetype(font_type, font_size_author) lines = [] line = "" @@ -75,8 +79,17 @@ def Convert(quote, author, fg, bg, font_type, font_size, width, height): draw.text((x, y), " - ", fg, font=font) y += font_size // 2 - author_width = draw.textsize(author, font)[0] + author_width = draw.textsize(author, font_author)[0] x = (width - author_width) // 2 - draw.text((x, y+15), author, fg, font=font) + draw.text((x, y+15), author, fg, font=font_author) + + if watermark_text: + if watermark_font_size is None: + watermark_font_size = font_size + watermark_font = ImageFont.truetype(font_type, watermark_font_size) + watermark_width, watermark_height = draw.textsize(watermark_text, watermark_font) + x = width - watermark_width - 10 + y = height - watermark_height - 10 + draw.text((x, y), watermark_text, fg, font=watermark_font) return image diff --git a/build/lib/Quote2Image/__init__.py b/build/lib/Quote2Image/__init__.py index d9543fc..00e62df 100644 --- a/build/lib/Quote2Image/__init__.py +++ b/build/lib/Quote2Image/__init__.py @@ -1,3 +1,3 @@ from .Quote2Image import ImgObject from .Quote2Image import GenerateColors -from .Quote2Image import Convert \ No newline at end of file +from .Quote2Image import Convert diff --git a/dist/Quote2Image-0.0.4.tar.gz b/dist/Quote2Image-0.0.4.tar.gz deleted file mode 100644 index 6253835..0000000 Binary files a/dist/Quote2Image-0.0.4.tar.gz and /dev/null differ diff --git a/dist/Quote2Image-0.0.4.win-amd64.zip b/dist/Quote2Image-0.0.4.win-amd64.zip deleted file mode 100644 index 1115fe4..0000000 Binary files a/dist/Quote2Image-0.0.4.win-amd64.zip and /dev/null differ diff --git a/dist/Quote2Image-0.0.4-py3-none-any.whl b/dist/Quote2Image-0.0.5-py3-none-any.whl similarity index 69% rename from dist/Quote2Image-0.0.4-py3-none-any.whl rename to dist/Quote2Image-0.0.5-py3-none-any.whl index 0a50235..f75fc6b 100644 Binary files a/dist/Quote2Image-0.0.4-py3-none-any.whl and b/dist/Quote2Image-0.0.5-py3-none-any.whl differ diff --git a/dist/Quote2Image-0.0.5.tar.gz b/dist/Quote2Image-0.0.5.tar.gz new file mode 100644 index 0000000..010f341 Binary files /dev/null and b/dist/Quote2Image-0.0.5.tar.gz differ diff --git a/setup.py b/setup.py index b6655d3..7307154 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh: long_description = "\n" + fh.read() -VERSION = "0.0.4" +VERSION = "0.0.5" DESCRIPTION = "A python module to convert text quotes into graphical images" LONG_DESCRIPTION = DESCRIPTION