tripleS-Dev commited on
Commit
dda97f6
β€’
1 Parent(s): 51c654e

update V1.3.1L Beta

Browse files
generate.py CHANGED
@@ -9,6 +9,8 @@ import edimg
9
  import edgif
10
  from PIL import Image, ImageDraw, ImageFont, ImageColor, ImageFilter, ImageSequence
11
 
 
 
12
 
13
  img_blank = Image.open('resource/blank.png')
14
 
@@ -119,40 +121,39 @@ back_ui = Image.open("resource/back_ui.png")
119
  outline_ui = Image.open("resource/outline.png")
120
  outline_ui_oma = Image.open("resource/outline_oma.png")
121
 
122
-
123
  sign_positions = {
124
- 1: (31, 1068),
125
- 2: (0, 1103),
126
- 3: (34, 1101),
127
- 4: (1, 1053),
128
- 5: (79, 1100),
129
- 6: (0, 1057),
130
- 7: (0, 1116),
131
- 8: (20, 1109),
132
- 9: (26, 1109),
133
- 10: (42, 1104),
134
- 11: (31, 1105),
135
- 12: (0, 1065),
136
- 13: (58, 1108),
137
- 14: (0, 1110),
138
- 15: (0, 1105),
139
- 16: (49, 1056),
140
- 17: (61, 1105),
141
- 18: (84, 1118),
142
- 19: (39, 1167),
143
- 20: (170, 1105),
144
- 21: (64, 1124),
145
- 22: (41, 1146),
146
- 23: (52, 1113),
147
- 24: (65, 1129),
148
-
149
- 25: (38, 1148),
150
- 26: (61, 1100),
151
- 27: (52, 1113),
152
- 28: (46, 1022),
153
- 29: (62, 1131)
154
  }
155
 
 
156
  cream01 = Image.open("resource/cream01.png")
157
  atom01 = Image.open("resource/atom01.png")
158
  binary01 = Image.open("resource/binary01.png")
@@ -237,13 +238,13 @@ def back(obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group
237
  width, height = logo.size
238
 
239
  # Calculate the new width to maintain the aspect ratio
240
- new_height = 117
241
  aspect_ratio = width / height
242
  new_width = int(new_height * aspect_ratio)
243
 
244
  # Resize the image
245
  logo = logo.resize((new_width, new_height), Image.Resampling.LANCZOS)
246
- img.paste(logo, (57, 151), logo)
247
 
248
 
249
  if member_name_dropdown:
@@ -311,13 +312,18 @@ def back(obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group
311
  img.paste(img_season,(53, 936), img_season)
312
  img.paste(img_season_outline, (53 + x, 936), img_season_outline)
313
 
314
- if sign != None:
315
- sign = sign + 1
316
  colored_icon = edimg.color(f'sign/{sign}.png', txt_color_hex)
317
- if sign in sign_positions:
318
- position = sign_positions[sign]
319
- img.paste(colored_icon, position, colored_icon)
320
-
 
 
 
 
 
 
321
 
322
  if qr_url_dropdown:
323
  url_txt = fn.url_mapping(qr_url_dropdown)
@@ -327,7 +333,22 @@ def back(obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group
327
  case "tripleS":
328
  img_qr_icon = edimg.qr_icon("resource/qr_icon_triples.png")
329
  img_qr.paste(img_qr_icon, (126, 126), img_qr_icon)
330
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  img_qr = edimg.resize_img(img_qr, 335,335)
332
  img.paste(img_qr, (555, 1098))
333
  else:
 
9
  import edgif
10
  from PIL import Image, ImageDraw, ImageFont, ImageColor, ImageFilter, ImageSequence
11
 
12
+ import maker
13
+ import pre
14
 
15
  img_blank = Image.open('resource/blank.png')
16
 
 
121
  outline_ui = Image.open("resource/outline.png")
122
  outline_ui_oma = Image.open("resource/outline_oma.png")
123
 
 
124
  sign_positions = {
125
+ "SeoYeon": (31, 1068),
126
+ "HyeRin": (0, 1103),
127
+ "JiWoo": (34, 1101),
128
+ "ChaeYeon": (1, 1053),
129
+ "YooYeon": (79, 1100),
130
+ "SooMin": (0, 1057),
131
+ "NaKyoung": (0, 1116),
132
+ "YuBin": (20, 1109),
133
+ "Kaede": (26, 1109),
134
+ "DaHyun": (42, 1104),
135
+ "Kotone": (31, 1105),
136
+ "YeonJi": (0, 1065),
137
+ "Nien": (58, 1108),
138
+ "SoHyun": (0, 1110),
139
+ "Xinyu": (0, 1105),
140
+ "Mayu": (49, 1056),
141
+ "Lynn": (61, 1105),
142
+ "JooBin": (84, 1118),
143
+ "HaYeon": (39, 1167),
144
+ "ShiOn": (170, 1105),
145
+ "ChaeWon": (64, 1124),
146
+ "Sullin": (41, 1146),
147
+ "SeoAh": (52, 1113),
148
+ "JiYeon": (65, 1129),
149
+ "HeeJin": (38, 1148),
150
+ "KimLip": (61, 1100),
151
+ "JinSoul": (52, 1113),
152
+ "Choerry": (46, 1022),
153
+ "HaSeul": (62, 1131)
 
154
  }
155
 
156
+
157
  cream01 = Image.open("resource/cream01.png")
158
  atom01 = Image.open("resource/atom01.png")
159
  binary01 = Image.open("resource/binary01.png")
 
238
  width, height = logo.size
239
 
240
  # Calculate the new width to maintain the aspect ratio
241
+ new_height = 126
242
  aspect_ratio = width / height
243
  new_width = int(new_height * aspect_ratio)
244
 
245
  # Resize the image
246
  logo = logo.resize((new_width, new_height), Image.Resampling.LANCZOS)
247
+ img.paste(logo, (61, 162), logo)
248
 
249
 
250
  if member_name_dropdown:
 
312
  img.paste(img_season,(53, 936), img_season)
313
  img.paste(img_season_outline, (53 + x, 936), img_season_outline)
314
 
315
+ if sign in pre.names:
 
316
  colored_icon = edimg.color(f'sign/{sign}.png', txt_color_hex)
317
+ position = sign_positions[sign]
318
+ img.paste(colored_icon, position, colored_icon)
319
+ elif sign:
320
+ colored_icon = edimg.color(f'/data/presets/{preset}/{sign}.png', txt_color_hex)
321
+ original_width, original_height = colored_icon.size
322
+ ratio = min(480 / original_width, 330 / original_height)
323
+ new_width = int(original_width * ratio)
324
+ new_height = int(original_height * ratio)
325
+ colored_icon = colored_icon.resize((new_width, new_height), Image.Resampling.LANCZOS)
326
+ img = maker.space(img, (63, 1097), (488, 335), colored_icon)
327
 
328
  if qr_url_dropdown:
329
  url_txt = fn.url_mapping(qr_url_dropdown)
 
333
  case "tripleS":
334
  img_qr_icon = edimg.qr_icon("resource/qr_icon_triples.png")
335
  img_qr.paste(img_qr_icon, (126, 126), img_qr_icon)
336
+ case 'None':
337
+ pass
338
+ case _:
339
+ img_qr_icon = Image.open(f'/data/presets/{preset}/qr_logo.png')
340
+ colored_icon = edimg.color(img_qr_icon, '#000000')
341
+
342
+ original_width, original_height = colored_icon.size
343
+ ratio = min(84 / original_width, 84 / original_height)
344
+ new_width = int(original_width * ratio)
345
+ new_height = int(original_height * ratio)
346
+ colored_icon = colored_icon.resize((new_width, new_height), Image.Resampling.LANCZOS)
347
+
348
+ qr_logo_bg = Image.new(size=(84, 84), mode='RGB', color=(255,255,255))
349
+ qr_logo_bg = maker.space(qr_logo_bg, (0,0), (84,84), colored_icon)
350
+
351
+ img_qr.paste(qr_logo_bg, (126, 126))
352
  img_qr = edimg.resize_img(img_qr, 335,335)
353
  img.paste(img_qr, (555, 1098))
354
  else:
main.py CHANGED
@@ -150,7 +150,7 @@ with gr.Blocks(theme=theme) as demo: # , js=js_func
150
  season_radio.change(fns.txt_season_visibility, season_radio, [season_txt, season_txt_outline])
151
 
152
 
153
- sign = gr.Dropdown(choices=pre.names, label="Sign", type='index')
154
 
155
 
156
  with gr.Accordion('QR Options'):
@@ -203,25 +203,25 @@ with gr.Blocks(theme=theme) as demo: # , js=js_func
203
  group_name = gr.Textbox(label="Group name", placeholder="aespa")
204
  company_name = gr.Textbox(label="Company name", placeholder="SM ent")
205
 
206
- top_logo_img = gr.Image(label="Top Logo", type='pil')
207
- qr_logo_img = gr.Image(label="QR Logo", type='pil')
208
-
209
- with gr.Accordion('Signs', open=True):
210
- with gr.Row():
211
- sign_img1 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
212
- sign_img2 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
213
- sign_img3 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
214
- sign_img4 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
215
- with gr.Row():
216
- sign_img5 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
217
- sign_img6 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
218
- sign_img7 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
219
- sign_img8 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
220
- with gr.Row():
221
- sign_img9 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
222
- sign_img10 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
223
- sign_img11 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
224
- sign_img12 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
225
 
226
  save = gr.Button(value="Save and Apply all")
227
 
 
150
  season_radio.change(fns.txt_season_visibility, season_radio, [season_txt, season_txt_outline])
151
 
152
 
153
+ sign = gr.Dropdown(choices=pre.names, label="Sign", type='value')
154
 
155
 
156
  with gr.Accordion('QR Options'):
 
203
  group_name = gr.Textbox(label="Group name", placeholder="aespa")
204
  company_name = gr.Textbox(label="Company name", placeholder="SM ent")
205
 
206
+ top_logo_img = gr.Image(label="Top Logo", type='pil', image_mode='RGBA')
207
+ qr_logo_img = gr.Image(label="QR Logo", type='pil', image_mode='RGBA')
208
+
209
+ with gr.Accordion('Signs', open=True):
210
+ with gr.Row():
211
+ sign_img1 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
212
+ sign_img2 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
213
+ sign_img3 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
214
+ sign_img4 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
215
+ with gr.Row():
216
+ sign_img5 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
217
+ sign_img6 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
218
+ sign_img7 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
219
+ sign_img8 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
220
+ with gr.Row():
221
+ sign_img9 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
222
+ sign_img10 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
223
+ sign_img11 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
224
+ sign_img12 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
225
 
226
  save = gr.Button(value="Save and Apply all")
227
 
maker.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import asyncio
2
+
3
+ from PIL import ImageFont, ImageDraw, Image
4
+
5
+ async def get_text_size(text, font_path, font_size, variation = None):
6
+ # 폰트λ₯Ό λ‘œλ“œν•©λ‹ˆλ‹€.
7
+ font = ImageFont.truetype(font_path, font_size)
8
+ if variation:
9
+ font.set_variation_by_name(variation)
10
+ # μž„μ‹œ 이미지λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
11
+ dummy_image = Image.new('RGB', (1, 1))
12
+ draw = ImageDraw.Draw(dummy_image)
13
+
14
+ # ν…μŠ€νŠΈμ˜ 크기λ₯Ό κ³„μ‚°ν•©λ‹ˆλ‹€.
15
+ text_bbox = draw.textbbox((0, 0), text, font=font)
16
+ text_size = (text_bbox[2] - text_bbox[0], text_bbox[3] - text_bbox[1])
17
+
18
+ return text_size
19
+
20
+
21
+ async def draw(font_size, text, color= (211, 213, 216), font_path = "75B.otf", variation = None):
22
+ font = ImageFont.truetype(font_path, font_size)
23
+ if variation:
24
+ font.set_variation_by_name(variation)
25
+ if font_path == 'inter.ttf':
26
+ offset_y = 10
27
+ else:
28
+ offset_y = 15
29
+ x, y = await get_text_size(text, font_path, font_size, variation)
30
+ image = Image.new("RGBA", (x, y+offset_y), (0, 0, 0, 0))
31
+ draw = ImageDraw.Draw(image)
32
+ draw.text((0, 0), text, fill=color, font=font)
33
+ return image
34
+
35
+
36
+ def space(base_img, box_position, box_size, objekt_img):
37
+
38
+ # 가상 μƒμž μœ„μΉ˜μ™€ 크기
39
+ x2, y2 = box_position
40
+ x3, y3 = box_size
41
+
42
+ # 객체 이미지 크기 κ°€μ Έμ˜€κΈ°
43
+ x4, y4 = objekt_img.size
44
+
45
+ # 쀑앙 μœ„μΉ˜ 계산
46
+ xc = x2 + (x3 - x4) / 2
47
+ yc = y2 + (y3 - y4) / 2
48
+
49
+ # 객체 이미지λ₯Ό 가상 μƒμžμ˜ 쀑앙에 뢙이기
50
+ base_img.paste(objekt_img, (int(xc), int(yc)), objekt_img)
51
+ return base_img
52
+
53
+
54
+ async def run():
55
+ (await draw(40, 'Binary01', font_path='inter.ttf', variation='Regular')).show()
56
+
57
+ #asyncio.run(run())
58
+
59
+ #font = ImageFont.truetype('HalvarBreit-XBd.ttf').get_variation_names()
60
+ #print(font)
pre.py CHANGED
@@ -1,5 +1,5 @@
1
  groups = ["tripleS", "ARTMS", "None"]
2
  groups_Other = ["tripleS", "ARTMS", "Other"]
3
  names = ["SeoYeon", "HyeRin", "JiWoo", "ChaeYeon", "YooYeon", "SooMin", "NaKyoung", "YuBin", "Kaede", "DaHyun", "Kotone", "YeonJi", "Nien", "SoHyun", "Xinyu", "Mayu", "Lynn", "JooBin", "HaYeon", "ShiOn", "ChaeWon", "Sullin", "SeoAh", "JiYeon", "HeeJin", "KimLip", "JinSoul", "Choerry", "HaSeul"]
4
- #login_uri = 'http://localhost:7860/'
5
- login_uri = 'https://chohj06ms-objektify2.hf.space/'
 
1
  groups = ["tripleS", "ARTMS", "None"]
2
  groups_Other = ["tripleS", "ARTMS", "Other"]
3
  names = ["SeoYeon", "HyeRin", "JiWoo", "ChaeYeon", "YooYeon", "SooMin", "NaKyoung", "YuBin", "Kaede", "DaHyun", "Kotone", "YeonJi", "Nien", "SoHyun", "Xinyu", "Mayu", "Lynn", "JooBin", "HaYeon", "ShiOn", "ChaeWon", "Sullin", "SeoAh", "JiYeon", "HeeJin", "KimLip", "JinSoul", "Choerry", "HaSeul"]
4
+ login_uri = 'http://localhost:7860/'
5
+ #login_uri = 'https://chohj06ms-objektify2.hf.space/'
preset_fn.py CHANGED
@@ -56,7 +56,7 @@ def create(userid, user_name, preset_name, group, artist, company, top_logo, qr_
56
  if isinstance(qr_logo, str):
57
  cairosvg.svg2png(url=qr_logo, write_to=f"{path}/qr_logo.png")
58
  else:
59
- qr_logo.save(f"{path}/qr_logo.png")
60
 
61
 
62
  signs = [sign_img1, sign_img2, sign_img3, sign_img4, sign_img5, sign_img6, sign_img7, sign_img8, sign_img9, sign_img10, sign_img11, sign_img12]
@@ -64,9 +64,9 @@ def create(userid, user_name, preset_name, group, artist, company, top_logo, qr_
64
 
65
  for i in range(len(artist)):
66
  if isinstance(signs[i], str):
67
- cairosvg.svg2png(url=signs[i], write_to=f"{path}/sign{i}.png")
68
  else:
69
- signs[i].save(f"{path}/sign{i}.png")
70
 
71
  data = {}
72
  data['userid'] = userid
 
56
  if isinstance(qr_logo, str):
57
  cairosvg.svg2png(url=qr_logo, write_to=f"{path}/qr_logo.png")
58
  else:
59
+ qr_logo.convert('RGBA').save(f"{path}/qr_logo.png")
60
 
61
 
62
  signs = [sign_img1, sign_img2, sign_img3, sign_img4, sign_img5, sign_img6, sign_img7, sign_img8, sign_img9, sign_img10, sign_img11, sign_img12]
 
64
 
65
  for i in range(len(artist)):
66
  if isinstance(signs[i], str):
67
+ cairosvg.svg2png(url=signs[i], write_to=f"{path}/{artist[i]}.png")
68
  else:
69
+ signs[i].save(f"{path}/{artist[i]}.png")
70
 
71
  data = {}
72
  data['userid'] = userid
sign/{21.png β†’ ChaeWon.png} RENAMED
File without changes
sign/{4.png β†’ ChaeYeon.png} RENAMED
File without changes
sign/{28.png β†’ Choerry.png} RENAMED
File without changes
sign/{10.png β†’ DaHyun.png} RENAMED
File without changes
sign/{29.png β†’ HaSeul.png} RENAMED
File without changes
sign/{19.png β†’ HaYeon.png} RENAMED
File without changes
sign/{25.png β†’ HeeJin.png} RENAMED
File without changes
sign/{2.png β†’ HyeRin.png} RENAMED
File without changes
sign/{3.png β†’ JiWoo.png} RENAMED
File without changes
sign/{24.png β†’ JiYeon.png} RENAMED
File without changes
sign/{27.png β†’ JinSoul.png} RENAMED
File without changes
sign/{18.png β†’ JooBin.png} RENAMED
File without changes
sign/{9.png β†’ Kaede.png} RENAMED
File without changes
sign/{26.png β†’ KimLip.png} RENAMED
File without changes
sign/{11.png β†’ Kotone.png} RENAMED
File without changes
sign/{17.png β†’ Lynn.png} RENAMED
File without changes
sign/{16.png β†’ Mayu.png} RENAMED
File without changes
sign/{7.png β†’ NaKyoung.png} RENAMED
File without changes
sign/{13.png β†’ Nien.png} RENAMED
File without changes
sign/{23.png β†’ SeoAh.png} RENAMED
File without changes
sign/{1.png β†’ SeoYeon.png} RENAMED
File without changes
sign/{20.png β†’ Shion.png} RENAMED
File without changes
sign/{14.png β†’ SoHyun.png} RENAMED
File without changes
sign/{6.png β†’ SooMin.png} RENAMED
File without changes
sign/{22.png β†’ Sullin.png} RENAMED
File without changes
sign/{15.png β†’ Xinyu.png} RENAMED
File without changes
sign/{12.png β†’ YeonJi.png} RENAMED
File without changes
sign/{5.png β†’ YooYeon.png} RENAMED
File without changes
sign/{8.png β†’ YuBin.png} RENAMED
File without changes