Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ from datetime import datetime
|
|
6 |
from PIL import Image, ImageDraw
|
7 |
from math import cos, sin, radians
|
8 |
|
|
|
9 |
def create_border_decoration(qr_image, decoration_style="Flowers"):
|
10 |
# Convert QR image to RGB mode first
|
11 |
qr_image = qr_image.convert('RGB')
|
@@ -21,6 +22,10 @@ def create_border_decoration(qr_image, decoration_style="Flowers"):
|
|
21 |
# Create new image with white background
|
22 |
decorated_image = Image.new('RGB', (new_width, new_height), 'white')
|
23 |
|
|
|
|
|
|
|
|
|
24 |
# Paste QR code in center
|
25 |
decorated_image.paste(qr_image, (padding, padding))
|
26 |
|
@@ -138,7 +143,7 @@ def create_border_decoration(qr_image, decoration_style="Flowers"):
|
|
138 |
|
139 |
return decorated_image
|
140 |
|
141 |
-
def create_qr(content, qr_type, fill_color, back_color, box_size, border_size, error_correction, border_decoration=""):
|
142 |
# QR 코드 데이터 포맷팅
|
143 |
formatted_data = format_data(content, qr_type)
|
144 |
|
@@ -164,8 +169,8 @@ def create_qr(content, qr_type, fill_color, back_color, box_size, border_size, e
|
|
164 |
# QR 이미지 생성
|
165 |
qr_img = qr.make_image(fill_color=fill_color, back_color=back_color)
|
166 |
|
167 |
-
# Add border decoration if specified and not
|
168 |
-
if border_decoration
|
169 |
qr_img = create_border_decoration(qr_img, border_decoration)
|
170 |
|
171 |
# 파일 저장
|
@@ -314,20 +319,22 @@ def create_interface():
|
|
314 |
|
315 |
border_decoration = gr.Dropdown(
|
316 |
choices=[
|
317 |
-
"
|
318 |
-
"
|
319 |
-
"
|
320 |
-
"
|
321 |
-
"
|
322 |
-
"
|
323 |
-
"
|
324 |
-
"
|
325 |
-
"
|
326 |
-
"
|
|
|
327 |
],
|
328 |
-
value="",
|
329 |
label="Border Decoration Style"
|
330 |
)
|
|
|
331 |
|
332 |
|
333 |
generate_btn = gr.Button(
|
|
|
6 |
from PIL import Image, ImageDraw
|
7 |
from math import cos, sin, radians
|
8 |
|
9 |
+
|
10 |
def create_border_decoration(qr_image, decoration_style="Flowers"):
|
11 |
# Convert QR image to RGB mode first
|
12 |
qr_image = qr_image.convert('RGB')
|
|
|
22 |
# Create new image with white background
|
23 |
decorated_image = Image.new('RGB', (new_width, new_height), 'white')
|
24 |
|
25 |
+
# Paste QR code in center
|
26 |
+
decorated_image.paste(qr_image, (padding, padding))
|
27 |
+
|
28 |
+
|
29 |
# Paste QR code in center
|
30 |
decorated_image.paste(qr_image, (padding, padding))
|
31 |
|
|
|
143 |
|
144 |
return decorated_image
|
145 |
|
146 |
+
def create_qr(content, qr_type, fill_color, back_color, box_size, border_size, error_correction, border_decoration="No Decoration"):
|
147 |
# QR 코드 데이터 포맷팅
|
148 |
formatted_data = format_data(content, qr_type)
|
149 |
|
|
|
169 |
# QR 이미지 생성
|
170 |
qr_img = qr.make_image(fill_color=fill_color, back_color=back_color)
|
171 |
|
172 |
+
# Add border decoration if specified and not "No Decoration"
|
173 |
+
if border_decoration != "No Decoration":
|
174 |
qr_img = create_border_decoration(qr_img, border_decoration)
|
175 |
|
176 |
# 파일 저장
|
|
|
319 |
|
320 |
border_decoration = gr.Dropdown(
|
321 |
choices=[
|
322 |
+
"No Decoration", # 명시적인 "장식 없음" 옵션
|
323 |
+
"Flowers",
|
324 |
+
"Hearts",
|
325 |
+
"Waves",
|
326 |
+
"Leaves",
|
327 |
+
"Stars",
|
328 |
+
"Chains",
|
329 |
+
"Bubbles",
|
330 |
+
"Vines",
|
331 |
+
"Diamonds",
|
332 |
+
"Lace"
|
333 |
],
|
334 |
+
value="No Decoration", # 기본값으로 "No Decoration" 설정
|
335 |
label="Border Decoration Style"
|
336 |
)
|
337 |
+
|
338 |
|
339 |
|
340 |
generate_btn = gr.Button(
|