ginipick commited on
Commit
2b46bb5
Β·
verified Β·
1 Parent(s): 5bcdffe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -11
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 RGBA if it's not
13
- if qr_image.mode in ('1', 'L'):
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('RGBA', (new_width, new_height), (255, 255, 255, 255))
26
 
27
- # Paste QR code in center - now with explicit size and convert to RGBA
28
- decorated_image.paste(qr_image, (padding, padding, padding + width, padding + height), qr_image)
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=(255, 192, 203, 255)) # lightpink in RGBA
50
- draw.ellipse([x-5, y-5, x+5, y+5], fill=(255, 255, 0, 255)) # yellow in RGBA
51
-
52
- # Convert back to RGB before saving
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"):