Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
13 changes: 13 additions & 0 deletions Text-to-Image/README.md
Original file line number Diff line number Diff line change
@@ -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
Binary file added Text-to-Image/fonts/Roboto-Black.ttf
Binary file not shown.
20 changes: 20 additions & 0 deletions Text-to-Image/text2image.py
Original file line number Diff line number Diff line change
@@ -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()