Spaces:
Runtime error
Runtime error
snowydabuffy
commited on
Commit
•
5e47220
1
Parent(s):
a2dfc43
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from PIL import Image, ImageDraw, ImageFont
|
3 |
+
|
4 |
+
def main():
|
5 |
+
st.title("Pokemon Card Generator")
|
6 |
+
|
7 |
+
# User inputs
|
8 |
+
name = st.text_input("Enter Pokemon name:")
|
9 |
+
card_type = st.selectbox("Select card type:", ["Normal", "EX"])
|
10 |
+
|
11 |
+
# Generate card button
|
12 |
+
if st.button("Generate card"):
|
13 |
+
st.write(f"Generating card for {name}...")
|
14 |
+
generate_card(name, card_type)
|
15 |
+
st.write(f"Custom Pokemon card generated for {name}!")
|
16 |
+
|
17 |
+
# Display custom card
|
18 |
+
image = Image.open(f"{name}_card.png")
|
19 |
+
st.image(image, caption=f"{name} {card_type} card", use_column_width=True)
|
20 |
+
|
21 |
+
def generate_card(name, card_type):
|
22 |
+
# Load card template
|
23 |
+
template = Image.open("card_template.png")
|
24 |
+
|
25 |
+
# Add Pokemon name
|
26 |
+
draw = ImageDraw.Draw(template)
|
27 |
+
font = ImageFont.truetype("arial.ttf", size=36)
|
28 |
+
draw.text((50, 50), name, font=font, fill=(255, 255, 255))
|
29 |
+
|
30 |
+
# Add card type
|
31 |
+
if card_type == "EX":
|
32 |
+
ex_logo = Image.open("ex_logo.png")
|
33 |
+
template.paste(ex_logo, (300, 100), ex_logo)
|
34 |
+
|
35 |
+
# Save custom card
|
36 |
+
template.save(f"{name}_card.png")
|
37 |
+
|
38 |
+
if __name__ == "__main__":
|
39 |
+
main()
|