Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,9 +9,8 @@ from math import cos, sin, radians
|
|
9 |
# ν
λ리 μ₯μ ν¨μ
|
10 |
# create_border_decoration ν¨μ μμ
|
11 |
def create_border_decoration(qr_image, decoration_prompt="flowers"):
|
12 |
-
# Convert QR image to
|
13 |
-
|
14 |
-
qr_image = qr_image.convert('RGBA')
|
15 |
|
16 |
# Get the size of the QR code image
|
17 |
width, height = qr_image.size
|
@@ -22,10 +21,10 @@ def create_border_decoration(qr_image, decoration_prompt="flowers"):
|
|
22 |
new_height = height + (padding * 2)
|
23 |
|
24 |
# Create new image with white background
|
25 |
-
decorated_image = Image.new('
|
26 |
|
27 |
-
# Paste QR code in center
|
28 |
-
decorated_image.paste(qr_image, (padding, padding
|
29 |
|
30 |
# Get draw object
|
31 |
draw = ImageDraw.Draw(decorated_image)
|
@@ -46,11 +45,10 @@ def create_border_decoration(qr_image, decoration_prompt="flowers"):
|
|
46 |
for angle in range(0, 360, 45): # 8 petals
|
47 |
x1 = x + petal_size * cos(radians(angle))
|
48 |
y1 = y + petal_size * sin(radians(angle))
|
49 |
-
draw.ellipse([x1-5, y1-5, x1+5, y1+5], fill=
|
50 |
-
draw.ellipse([x-5, y-5, x+5, y+5], fill=
|
51 |
-
|
52 |
-
|
53 |
-
return decorated_image.convert('RGB')
|
54 |
|
55 |
# QR μ½λ μμ± ν¨μ
|
56 |
def create_qr(content, qr_type, fill_color, back_color, box_size, border_size, error_correction, border_decoration="flowers"):
|
|
|
9 |
# ν
λ리 μ₯μ ν¨μ
|
10 |
# create_border_decoration ν¨μ μμ
|
11 |
def create_border_decoration(qr_image, decoration_prompt="flowers"):
|
12 |
+
# Convert QR image to RGB mode first
|
13 |
+
qr_image = qr_image.convert('RGB')
|
|
|
14 |
|
15 |
# Get the size of the QR code image
|
16 |
width, height = qr_image.size
|
|
|
21 |
new_height = height + (padding * 2)
|
22 |
|
23 |
# Create new image with white background
|
24 |
+
decorated_image = Image.new('RGB', (new_width, new_height), 'white')
|
25 |
|
26 |
+
# Paste QR code in center (with RGB mode)
|
27 |
+
decorated_image.paste(qr_image, (padding, padding))
|
28 |
|
29 |
# Get draw object
|
30 |
draw = ImageDraw.Draw(decorated_image)
|
|
|
45 |
for angle in range(0, 360, 45): # 8 petals
|
46 |
x1 = x + petal_size * cos(radians(angle))
|
47 |
y1 = y + petal_size * sin(radians(angle))
|
48 |
+
draw.ellipse([x1-5, y1-5, x1+5, y1+5], fill='pink')
|
49 |
+
draw.ellipse([x-5, y-5, x+5, y+5], fill='yellow') # Center of flower
|
50 |
+
|
51 |
+
return decorated_image
|
|
|
52 |
|
53 |
# QR μ½λ μμ± ν¨μ
|
54 |
def create_qr(content, qr_type, fill_color, back_color, box_size, border_size, error_correction, border_decoration="flowers"):
|