diff --git a/README.md b/README.md index e94f5b33..d52651ff 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,9 @@ Incase there is something that needs to be followed while executing the python s | Simple TCP Chat Server | [Simple TCP Chat Server](https://github.com/DhanushNehru/Python-Scripts/tree/master/TCP%20Chat%20Server) | Creates a local server on your LAN for receiving and sending messages! | | Snake Water Gun | [Snake Water Gun](https://github.com/DhanushNehru/Python-Scripts/tree/master/Snake-Water-Gun) | A game similar to Rock Paper Scissors. | | Star Pattern | [Star Pattern](https://github.com/DhanushNehru/Python-Scripts/tree/master/Star%20Pattern) | Creates a star pattern pyramid | -| Take a break | [Take a break](https://github.com/DhanushNehru/Python-Scripts/tree/master/Take%20A%20Break) | Python code to take a break while working long hours TakeABreak.py | +| Take a break | [Take a break](https://github.com/DhanushNehru/Python-Scripts/tree/master/Take%20A%20Break) | Python code to take a break while working long hours TakeABreak.py +| Text to Image | [Text to Image](https://github.com/DhanushNehru/Python-Scripts/tree/master/Text-to-Image) | A +Python script that will take your text and convert it to a JPEG | Tic Tac Toe | [Tic Tac Toe](https://github.com/DhanushNehru/Python-Scripts/tree/master/Tic-Tac-Toe) | A game of Tic Tac Toe. | | Tik Tac Toe | [Tik Tac Toe](https://github.com/DhanushNehru/Python-Scripts/tree/master/TIK-TAC-TOE) | A game of Tik Tac Toe. | | Turtle Art & Patterns | [Turtle Art](https://github.com/DhanushNehru/Python-Scripts/tree/master/Turtle_Art) | Scripts to view turtle art also has prompt based ones | diff --git a/Text-to-Image/README.md b/Text-to-Image/README.md new file mode 100644 index 00000000..81fc9869 --- /dev/null +++ b/Text-to-Image/README.md @@ -0,0 +1,13 @@ +# Text-to-Image + +## Usage +Run the text2image.py file from the directory where the Python-Scripts folder is located in and it will prompt you will all the required inputs + +### Example +```bash +cd code +python3 code/Python-Scripts/Text-To-Image/text2image.py +``` + +## Output +The saved JPEG file will be located in the directory \ No newline at end of file diff --git a/Text-to-Image/fonts/Roboto-Black.ttf b/Text-to-Image/fonts/Roboto-Black.ttf new file mode 100644 index 00000000..0112e7da Binary files /dev/null and b/Text-to-Image/fonts/Roboto-Black.ttf differ diff --git a/Text-to-Image/text2image.py b/Text-to-Image/text2image.py new file mode 100644 index 00000000..018021be --- /dev/null +++ b/Text-to-Image/text2image.py @@ -0,0 +1,20 @@ +from PIL import Image, ImageDraw, ImageFont + +def main(): + # Get filename for image + filename = input("What would you like your image to be called?") + # Create white background image + img = Image.new(mode="RGB", size=(1920,1080), color='#FFFFFF') + d1 = ImageDraw.Draw(img) + # Get text for the image + writing = input("Write your text here: ") + # Choose the font + fnt = ImageFont.truetype("Python-Scripts/Text-to-Image/fonts/Roboto-Black.ttf", 40) + # Write the text + d1.text((65, 10), writing, fill=(255,0,0), font=fnt) + # Show & save the image + img.show() + img.save(filename + ".jpeg") + +if __name__ == '__main__': + main() \ No newline at end of file