Spaces:
Running
Running
tripleS-Dev
commited on
Commit
โข
5ad9ad5
1
Parent(s):
bf9d1b4
update V1.3.8
Browse files-Add meta V1 front
-Add QR caption
- generate.py +6 -1
- main.py +5 -3
- maker.py +17 -6
generate.py
CHANGED
@@ -203,7 +203,7 @@ right_modhaus = Image.open("resource/right_modhaus.png")
|
|
203 |
img_qr_white_space = Image.new("RGB", (335, 335), 'white')
|
204 |
|
205 |
|
206 |
-
def back(obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group_name_radio, group_name_txt, member_name_dropdown, obj_num, obj_alphabet, obj_alphabet_txt, obj_serial, obj_outline_color, obj_outline_color_picker, logo_radio, class_radio, class_txt, season_radio, season_txt, season_txt_outline, sign, qr_url_dropdown, qr_Logo_radio, right_btn, preset):
|
207 |
match obj_color:
|
208 |
case 'OMA1':
|
209 |
frame = outline_ui_oma
|
@@ -400,6 +400,11 @@ def back(obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group
|
|
400 |
else:
|
401 |
img.paste(img_qr_white_space,(555, 1098))
|
402 |
|
|
|
|
|
|
|
|
|
|
|
403 |
if right_btn:
|
404 |
img_right_modhaus = edimg.color(right_modhaus, txt_color_hex)
|
405 |
img.paste(img_right_modhaus, (61,1604), img_right_modhaus)
|
|
|
203 |
img_qr_white_space = Image.new("RGB", (335, 335), 'white')
|
204 |
|
205 |
|
206 |
+
def back(obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group_name_radio, group_name_txt, member_name_dropdown, obj_num, obj_alphabet, obj_alphabet_txt, obj_serial, obj_outline_color, obj_outline_color_picker, logo_radio, class_radio, class_txt, season_radio, season_txt, season_txt_outline, sign, qr_url_dropdown, qr_Logo_radio, right_btn, preset, qr_caption):
|
207 |
match obj_color:
|
208 |
case 'OMA1':
|
209 |
frame = outline_ui_oma
|
|
|
400 |
else:
|
401 |
img.paste(img_qr_white_space,(555, 1098))
|
402 |
|
403 |
+
if qr_caption:
|
404 |
+
qr_caption_img = maker.draw(36, qr_caption, color=txt_color_hex)
|
405 |
+
img = maker.space(img, (553, 1453), (339,37), qr_caption_img)
|
406 |
+
|
407 |
+
|
408 |
if right_btn:
|
409 |
img_right_modhaus = edimg.color(right_modhaus, txt_color_hex)
|
410 |
img.paste(img_right_modhaus, (61,1604), img_right_modhaus)
|
main.py
CHANGED
@@ -252,7 +252,9 @@ with gr.Blocks(theme=theme, js=animation, head=ga_script, analytics_enabled=True
|
|
252 |
with gr.Accordion('QR Options'):
|
253 |
qr_url_dropdown = gr.Dropdown(["tripleS website", "tripleS youtube", "tripleS ๐", "tripleS discord"], label="QR url", info="Can write any url", allow_custom_value=True, value='https://objektify.xyz')
|
254 |
|
255 |
-
|
|
|
|
|
256 |
|
257 |
|
258 |
right_btn = gr.Checkbox(label="Add Rights", value=False, interactive=True)
|
@@ -437,14 +439,14 @@ with gr.Blocks(theme=theme, js=animation, head=ga_script, analytics_enabled=True
|
|
437 |
group_name_txt, member_name_dropdown, obj_num, obj_alphabet, obj_alphabet_txt,
|
438 |
obj_serial, obj_outline_color, obj_outline_color_picker, logo_radio, class_radio,
|
439 |
class_txt, season_radio, season_txt, season_txt_outline, sign, qr_url_dropdown,
|
440 |
-
qr_Logo_radio, right_btn, preset], outputs=[outputs2, ex_img_b])
|
441 |
|
442 |
back_tab.select(fn=generate.back,
|
443 |
inputs=[obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group_name_radio,
|
444 |
group_name_txt, member_name_dropdown, obj_num, obj_alphabet, obj_alphabet_txt, obj_serial,
|
445 |
obj_outline_color, obj_outline_color_picker, logo_radio, class_radio, class_txt,
|
446 |
season_radio, season_txt, season_txt_outline, sign, qr_url_dropdown, qr_Logo_radio,
|
447 |
-
right_btn, preset], outputs=[preview, ex_img_b])
|
448 |
|
449 |
ex_btn.click(fn=generate.ex_gen, inputs=[ex_img_f, ex_file_f, ex_img_b, ex_gen_file_count, ex_hide_blur, ex_hide_blur_range, watermark], outputs=[ex_img_f_out, ex_img_b_out])
|
450 |
demo.load(fn=login_discord.id_check, outputs=[login, dev, rec, userid, beta, preset])
|
|
|
252 |
with gr.Accordion('QR Options'):
|
253 |
qr_url_dropdown = gr.Dropdown(["tripleS website", "tripleS youtube", "tripleS ๐", "tripleS discord"], label="QR url", info="Can write any url", allow_custom_value=True, value='https://objektify.xyz')
|
254 |
|
255 |
+
with gr.Row():
|
256 |
+
qr_Logo_radio = gr.Radio(["tripleS", "None"], label="QR Logo", value="None", interactive=True)
|
257 |
+
qr_caption = gr.Textbox(label='caption')
|
258 |
|
259 |
|
260 |
right_btn = gr.Checkbox(label="Add Rights", value=False, interactive=True)
|
|
|
439 |
group_name_txt, member_name_dropdown, obj_num, obj_alphabet, obj_alphabet_txt,
|
440 |
obj_serial, obj_outline_color, obj_outline_color_picker, logo_radio, class_radio,
|
441 |
class_txt, season_radio, season_txt, season_txt_outline, sign, qr_url_dropdown,
|
442 |
+
qr_Logo_radio, right_btn, preset, qr_caption], outputs=[outputs2, ex_img_b])
|
443 |
|
444 |
back_tab.select(fn=generate.back,
|
445 |
inputs=[obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group_name_radio,
|
446 |
group_name_txt, member_name_dropdown, obj_num, obj_alphabet, obj_alphabet_txt, obj_serial,
|
447 |
obj_outline_color, obj_outline_color_picker, logo_radio, class_radio, class_txt,
|
448 |
season_radio, season_txt, season_txt_outline, sign, qr_url_dropdown, qr_Logo_radio,
|
449 |
+
right_btn, preset, qr_caption], outputs=[preview, ex_img_b])
|
450 |
|
451 |
ex_btn.click(fn=generate.ex_gen, inputs=[ex_img_f, ex_file_f, ex_img_b, ex_gen_file_count, ex_hide_blur, ex_hide_blur_range, watermark], outputs=[ex_img_f_out, ex_img_b_out])
|
452 |
demo.load(fn=login_discord.id_check, outputs=[login, dev, rec, userid, beta, preset])
|
maker.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
|
2 |
|
3 |
from PIL import ImageFont, ImageDraw, Image
|
4 |
|
5 |
-
|
6 |
# ํฐํธ๋ฅผ ๋ก๋ํฉ๋๋ค.
|
7 |
font = ImageFont.truetype(font_path, font_size)
|
8 |
if variation:
|
@@ -18,7 +18,20 @@ async def get_text_size(text, font_path, font_size, variation = None):
|
|
18 |
return text_size
|
19 |
|
20 |
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
font = ImageFont.truetype(font_path, font_size)
|
23 |
if variation:
|
24 |
font.set_variation_by_name(variation)
|
@@ -26,7 +39,7 @@ async def draw(font_size, text, color= (211, 213, 216), font_path = "75B.otf", v
|
|
26 |
offset_y = 10
|
27 |
else:
|
28 |
offset_y = 15
|
29 |
-
x, y =
|
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)
|
@@ -51,8 +64,6 @@ def space(base_img, box_position, box_size, 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 |
|
|
|
1 |
+
|
2 |
|
3 |
from PIL import ImageFont, ImageDraw, Image
|
4 |
|
5 |
+
def get_text_size(text, font_path, font_size, variation = None):
|
6 |
# ํฐํธ๋ฅผ ๋ก๋ํฉ๋๋ค.
|
7 |
font = ImageFont.truetype(font_path, font_size)
|
8 |
if variation:
|
|
|
18 |
return text_size
|
19 |
|
20 |
|
21 |
+
def hex_to_rgb(hex_color):
|
22 |
+
# Remove the hash at the start if it's there
|
23 |
+
hex_color = hex_color.lstrip('#')
|
24 |
+
|
25 |
+
# Convert the string into integer values, then into a tuple
|
26 |
+
rgb_tuple = tuple(int(hex_color[i:i + 2], 16) for i in (0, 2, 4))
|
27 |
+
|
28 |
+
return rgb_tuple
|
29 |
+
|
30 |
+
|
31 |
+
def draw(font_size, text, color= (211, 213, 216), font_path = "./font/Helvetica_Neue_LT_Std_75_Bold.otf", variation = None):
|
32 |
+
if isinstance(color, str):
|
33 |
+
color = hex_to_rgb(color)
|
34 |
+
|
35 |
font = ImageFont.truetype(font_path, font_size)
|
36 |
if variation:
|
37 |
font.set_variation_by_name(variation)
|
|
|
39 |
offset_y = 10
|
40 |
else:
|
41 |
offset_y = 15
|
42 |
+
x, y = get_text_size(text, font_path, font_size, variation)
|
43 |
image = Image.new("RGBA", (x, y+offset_y), (0, 0, 0, 0))
|
44 |
draw = ImageDraw.Draw(image)
|
45 |
draw.text((0, 0), text, fill=color, font=font)
|
|
|
64 |
return base_img
|
65 |
|
66 |
|
|
|
|
|
67 |
|
68 |
#asyncio.run(run())
|
69 |
|