Skip to content
This repository was archived by the owner on May 19, 2022. It is now read-only.

Commit 9ff0fdb

Browse files
author
Rosetta Emerson / こじめ
committed
initial commit
0 parents  commit 9ff0fdb

File tree

6 files changed

+48
-0
lines changed

6 files changed

+48
-0
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Persona 5 Calling Card Maker, now open source.
2+
3+
You can try this without having to download the program at [my website](https://skyventuree.github.io/tools/p5cc).
4+
5+
# Installation
6+
Install required modules:
7+
8+
`pip3 install -r requirements.txt`
9+
10+
And then run it!
11+
12+
`python3 p5cc.py <filePathToSave> <message>`

assets/background.png

108 KB
Loading

assets/earwig-factory.ttf

62.4 KB
Binary file not shown.

assets/logo.png

46.1 KB
Loading

p5cc.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from PIL import Image, ImageDraw, ImageFont
2+
import textwrap, sys
3+
4+
# configuration
5+
FONT_PATH = "./assets/earwig-factory.ttf"
6+
FONT_SIZE = 120
7+
WRAPPER_WIDTH = 24
8+
BACKGROUND = "./assets/background.png"
9+
P5_LOGO = "./assets/logo.png"
10+
11+
def p5cc(message, savePath):
12+
lines = message.split("\n")
13+
lists = (textwrap.TextWrapper(width=WRAPPER_WIDTH,break_long_words=False).wrap(line) for line in lines)
14+
para = "\n".join("\n".join(list) for list in lists)
15+
16+
bg = Image.open(BACKGROUND)
17+
logo = Image.open(P5_LOGO)
18+
MAX_W, MAX_H = bg.size
19+
20+
draw = ImageDraw.Draw(bg)
21+
font = ImageFont.truetype(FONT_PATH, FONT_SIZE)
22+
23+
w, h = draw.textsize(para, font=font)
24+
draw.text(((MAX_W-w)/2,(MAX_H-h)/2), para, font=font, fill="white", align='center', stroke_width=12, stroke_fill='black')
25+
26+
im.paste(logo, (MAX_W - 300, MAX_H - 300), logo)
27+
im.save(savePath)
28+
29+
if __name__ == "__main__":
30+
if len(sys.argv <= 2):
31+
print("Usage: {} <filePath> <message>".format(sys.argv[0]))
32+
else:
33+
p5cc(sys.argv[2:], sys.argv[1])
34+
print("Your calling card has been saved at " + sys.argv[1])

requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pillow
2+
textwrap

0 commit comments

Comments
 (0)