File size: 21,406 Bytes
066e3f2
726afd0
3e8ff37
066e3f2
 
 
 
 
 
3e8ff37
997dacc
dda97f6
 
239804b
 
 
066e3f2
 
5c09508
 
 
 
066e3f2
239804b
76f5da6
066e3f2
 
 
 
997dacc
3e8ff37
a819cd4
 
 
239804b
7841a2b
3e8ff37
7841a2b
997dacc
 
066e3f2
 
 
 
239804b
066e3f2
5c09508
10a3a6c
066e3f2
239804b
066e3f2
3e8ff37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
066e3f2
 
 
5c09508
 
066e3f2
 
5c09508
 
066e3f2
 
5c09508
 
066e3f2
 
5c09508
 
10a3a6c
 
 
 
066e3f2
f050b9c
10a3a6c
 
 
 
5c09508
 
 
 
066e3f2
 
5c09508
 
066e3f2
 
5c09508
066e3f2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3e8ff37
d10d21b
 
 
239804b
 
 
 
 
 
 
 
066e3f2
 
 
 
 
 
 
 
 
 
5c09508
997dacc
3e8ff37
5c09508
066e3f2
3e8ff37
 
066e3f2
3e8ff37
 
 
066e3f2
5c09508
066e3f2
 
dda97f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
066e3f2
 
dda97f6
066e3f2
 
 
 
10a3a6c
066e3f2
5c09508
 
 
 
 
066e3f2
5c09508
 
066e3f2
5c09508
 
5ad9ad5
0f2abb8
 
 
 
 
 
 
d10d21b
066e3f2
 
d10d21b
066e3f2
d10d21b
066e3f2
d10d21b
066e3f2
 
 
 
 
 
5c09508
066e3f2
 
5c09508
066e3f2
 
5c09508
066e3f2
 
5c09508
10a3a6c
 
 
066e3f2
cf4ab06
10a3a6c
 
 
5c09508
 
 
 
066e3f2
 
5c09508
066e3f2
 
 
5c09508
d10d21b
5c09508
066e3f2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d10d21b
 
 
239804b
 
d10d21b
 
 
 
dda97f6
d10d21b
 
 
 
 
dda97f6
066e3f2
 
 
 
 
 
 
a6b59f9
066e3f2
 
 
 
 
 
 
 
 
 
 
239804b
066e3f2
 
 
 
 
 
 
 
 
 
 
d10d21b
 
 
239804b
 
 
 
 
 
 
 
 
 
 
 
 
d10d21b
066e3f2
 
10a3a6c
066e3f2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10a3a6c
 
 
066e3f2
 
 
 
 
 
 
dda97f6
066e3f2
dda97f6
 
 
 
 
 
 
 
 
 
066e3f2
 
 
 
 
 
 
 
 
ab5cb0f
 
 
dda97f6
 
 
 
afe5a9d
dda97f6
 
 
 
 
 
 
 
 
 
 
066e3f2
 
 
 
 
5ad9ad5
 
 
 
 
066e3f2
 
 
d10d21b
066e3f2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
import os
import time
import uuid
import numpy as np

import gradio as gr
import fn
import edimg
import edgif
from PIL import Image, ImageDraw, ImageFont, ImageColor, ImageFilter, ImageSequence, PngImagePlugin
from copy import deepcopy
import maker
import pre
import pandas as pd

from edimg import qr_icon

img_blank = Image.open('resource/blank.png')
side = Image.open("resources/side.png")
side_special = Image.open("resources/side_special.png")
side_oma1 = Image.open("resources/side_oma1.png")
side_oma2 = Image.open("resources/side_oma2.png")

def sorting(img_type, img_static, img_dynamic_file, obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, member_name_dropdown, group_name_radio, group_name_txt, obj_num, obj_alphabet, obj_alphabet_txt, obj_serial, horizontal, preset):

    match img_type:
        case "Image":
            if img_static == None:
                gr.Warning("Upload the image first")
                return "resource/upload_first.png", "resource/upload_first.png", None, None
            img_static = Image.open(img_static)
            if not img_static.size == (1164, 1800):
                img_static = edimg.resize_img(img_static, 1164, 1800)
                print('resized!')
            img, img_copy = front_static(img_static, obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, member_name_dropdown, group_name_radio, group_name_txt, obj_num, obj_alphabet, obj_alphabet_txt, obj_serial, preset)
            if horizontal:
                img = Image.open(img)
                img_rotate = img.rotate(90, expand=True)
                return img_rotate, img, None, img_copy
            return img, img, None, img_copy
        case "Gif":
            if img_dynamic_file == None:
                gr.Warning("Upload the gif first")
                return "resource/upload_first.png", "resource/upload_first.png", None
            _, overlay = front_static(img_blank, obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, member_name_dropdown, group_name_radio, group_name_txt, obj_num, obj_alphabet, obj_alphabet_txt, obj_serial, preset)
            gif = Image.open(img_dynamic_file)
            edgif.attach_gif(gif, overlay)
            return "output.gif", "output.gif", "output.gif", None

def front_static(img, obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, member_name_dropdown, group_name_radio, group_name_txt, obj_num, obj_alphabet, obj_alphabet_txt, obj_serial, preset):

    meta = PngImagePlugin.PngInfo()
    meta.add_text('objektify', 'V1')
    meta.add_text("obj_color", obj_color if obj_color is not None else "")
    meta.add_text("obj_color_picker", obj_color_picker if obj_color_picker is not None else "")
    meta.add_text("ai_num", str(ai_num) if str(ai_num) is not None else "")
    meta.add_text("txt_color", txt_color if txt_color is not None else "")
    meta.add_text("txt_color_picker", txt_color_picker if txt_color_picker is not None else "")
    meta.add_text("member_name_dropdown", member_name_dropdown if member_name_dropdown is not None else "")
    meta.add_text("group_name_radio", group_name_radio if group_name_radio is not None else "")
    meta.add_text("group_name_txt", group_name_txt if group_name_txt is not None else "")
    meta.add_text("obj_num", obj_num if obj_num is not None else "")
    meta.add_text("obj_alphabet", obj_alphabet if obj_alphabet is not None else "")
    meta.add_text("obj_alphabet_txt", obj_alphabet_txt if obj_alphabet_txt is not None else "")
    meta.add_text("obj_serial", obj_serial if obj_serial is not None else "")


    match obj_color:
        case "Atom01":
            obj_color = "#ffdd00"
            front_side = edimg.color(side, obj_color)
            img.paste(front_side, (1039, 104), front_side)
        case "Binary01":
            obj_color = "#00ff01"
            front_side = edimg.color(side, obj_color)
            img.paste(front_side, (1039, 104), front_side)
        case "Cream01":
            obj_color = "#ff7477"
            front_side = edimg.color(side, obj_color)
            img.paste(front_side, (1039, 104), front_side)
        case "Divine01":
            obj_color = "#a226f5"
            front_side = edimg.color(side, obj_color)
            img.paste(front_side, (1039, 104), front_side)
        case "Ever01":
            obj_color = "#33ecfd"
            front_side = edimg.color(side, obj_color)
            img.paste(front_side, (1039, 104), front_side)
        case "Special":
            img.paste(side_special, (1039, 104), side_special)
        case "Premier":
            obj_color = "#2E3192"
            front_side = edimg.color(side, obj_color)
            img.paste(front_side, (1039, 104), front_side)
        case "OMA1":
            img = edimg.paste_img(img, side_oma1, (1016, 83))
        case "OMA2":
            img = edimg.paste_img(img, side_oma2, (1016, 83))
        case "Other color":
            obj_color = obj_color_picker
            front_side = edimg.color(side, obj_color)
            img.paste(front_side, (1039, 104), front_side)
        case "AI Color":
            front_side = edimg.color_ai(ai_num)
            img.paste(front_side, (1039, 0), front_side)


    match txt_color:
        case "White":
            txt_color_r = 255
            txt_color_g = 255
            txt_color_b = 255
            txt_color_hex = "#FFFFFF"
        case "Black":
            txt_color_r = 0
            txt_color_g = 0
            txt_color_b = 0
            txt_color_hex = "#000000"
        case _:
            txt_color_r, txt_color_g, txt_color_b = fn.hex_to_rgb(txt_color_picker)
            txt_color_hex = txt_color_picker


    if member_name_dropdown:
        img_name = edimg.txt(member_name_dropdown, txt_color_r, txt_color_g, txt_color_b, 61, 270, "l")
        img.paste(img_name, (1050, 161), img_name)

    match group_name_radio:
        case "tripleS":
            img_group_name = edimg.txt(group_name_radio, txt_color_r, txt_color_g, txt_color_b, 61, 270, "r")
            img.paste(img_group_name, (1050, 1240), img_group_name)
        case "ARTMS":
            img_artms_side = edimg.color("resource/artms_side.png", txt_color_hex)
            img.paste(img_artms_side, (1081, 1371), img_artms_side)
        case "Other":
            img_group_name = edimg.txt(group_name_txt, txt_color_r, txt_color_g, txt_color_b, 61, 270, "r")
            img.paste(img_group_name, (1050, 1240), img_group_name)
            group_name_radio = group_name_txt
        case None:
            pass
        case _:

            if os.path.isfile(f'/data/presets/{preset}/sideNameImage.png'):
                sideNameImage = edimg.color(f'/data/presets/{preset}/sideNameImage.png', txt_color_hex)
                #sideNameImage.show()
                img.paste(sideNameImage, (1058, 1640-sideNameImage.size[1]), sideNameImage)
            else:
                img_group_name = edimg.txt(group_name_radio, txt_color_r, txt_color_g, txt_color_b, 61, 270, "r")
                img.paste(img_group_name, (1050, 1240), img_group_name)

    if obj_num != "" and obj_alphabet != "":
        if obj_alphabet == "Other":
            obj_alphabet = obj_alphabet_txt
        img_obj_num = edimg.txt(obj_num+obj_alphabet, txt_color_r, txt_color_g, txt_color_b, 75, 270, "r")
        img.paste(img_obj_num, (1050, 452), img_obj_num)

    if obj_serial:
        img_serial = edimg.serial(obj_serial, txt_color_r, txt_color_g, txt_color_b, 75)
        img.paste(img_serial, (1046, 871), img_serial)

    img_copy = deepcopy(img)

    img = edimg.rounded(img)



    krtime = fn.get_kr_time()

    img.save(f'/data/cache/objektify-{krtime}.png', pnginfo=meta)
    return f'/data/cache/objektify-{krtime}.png', img_copy



sign_positions = {
    "SeoYeon": (31, 1068),
    "HyeRin": (0, 1103),
    "JiWoo": (34, 1101),
    "ChaeYeon": (1, 1053),
    "YooYeon": (79, 1100),
    "SooMin": (0, 1057),
    "NaKyoung": (0, 1116),
    "YuBin": (20, 1109),
    "Kaede": (26, 1109),
    "DaHyun": (42, 1104),
    "Kotone": (31, 1105),
    "YeonJi": (0, 1065),
    "Nien": (58, 1108),
    "SoHyun": (0, 1110),
    "Xinyu": (0, 1105),
    "Mayu": (49, 1056),
    "Lynn": (61, 1105),
    "JooBin": (84, 1118),
    "HaYeon": (39, 1167),
    "ShiOn": (170, 1105),
    "ChaeWon": (64, 1124),
    "Sullin": (41, 1146),
    "SeoAh": (52, 1113),
    "JiYeon": (65, 1129),
    "HeeJin": (38, 1148),
    "KimLip": (61, 1100),
    "JinSoul": (52, 1113),
    "Choerry": (46, 1022),
    "HaSeul": (62, 1131)
}


cream01 = Image.open("resource/cream01.png")
atom01 = Image.open("resource/atom01.png")
binary01 = Image.open("resource/binary01.png")
divine01 = Image.open("resource/divine01.png")
ever01 = Image.open("resource/ever01.png")

back_ui = Image.open("resource/back_ui.png")
outline_ui = Image.open("resources/outline.png")
outline_ui_oma = Image.open("resources/outline_oma.png")
back_ = Image.open("resources/back.png")

right_modhaus = Image.open("resource/right_modhaus.png")


img_qr_white_space = Image.new("RGB", (335, 335), 'white')


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):
    match obj_color:
        case 'OMA1':
            frame = outline_ui_oma
        case 'OMA2':
            frame = outline_ui_oma
        case _:
            frame = outline_ui

    match obj_outline_color:
        case "White":
            outline = edimg.color(frame, "#FFFFFF")
        case "Black":
            outline = edimg.color(frame, "#000000")
        case _:
            outline = edimg.color(frame, obj_outline_color_picker)



    match obj_color:
        case "Atom01":
            obj_color = "#ffdd00"
            img = edimg.color(back_, obj_color)
        case "Binary01":
            obj_color = "#00ff01"
            img = edimg.color(back_, obj_color)
        case "Cream01":
            obj_color = "#ff7477"
            img = edimg.color(back_, obj_color)
        case "Divine01":
            obj_color = "#a226f5"
            img = edimg.color(back_, obj_color)
        case "Ever01":
            obj_color = "#33ecfd"
            img = edimg.color(back_, obj_color)
        case "Special":
            img = Image.open('resources/back_special.png')
        case "Premier":
            obj_color = "#2E3192"
            img = edimg.color(back_, obj_color)
        case "OMA1":
            img = Image.open('resources/back_oma1.png')
        case "OMA2":
            img = Image.open('resources/back_oma2.png')
        case "Other color":
            obj_color = obj_color_picker
            img = edimg.color(back_, obj_color)
        case "AI Color":
            img = edimg.color_ai_back(ai_num)
        case _:
            img = edimg.color(back_, '#ffffff')

    img.paste(outline, (0, 0), outline)

    match txt_color:
        case "White":
            txt_color_r = 255
            txt_color_g = 255
            txt_color_b = 255
            txt_color_hex = "#FFFFFF"
        case "Black":
            txt_color_r = 0
            txt_color_g = 0
            txt_color_b = 0
            txt_color_hex = "#000000"
        case _:
            txt_color_r, txt_color_g, txt_color_b = fn.hex_to_rgb(txt_color_picker)
            txt_color_hex = txt_color_picker

    back_ui_colored = edimg.color(back_ui, txt_color_hex)
    img.paste(back_ui_colored, (0, 0), back_ui_colored)


    match logo_radio:
        case "tripleS":
            logo = edimg.color('resource/triples_logo.png', txt_color_hex)
            img.paste(logo, (61, 162), logo)
        case "ARTMS":
            logo = edimg.color('resource/artms_logo.png', txt_color_hex)
            img.paste(logo, (61, 162), logo)
        case 'None':
            pass
        case _:


            logo = edimg.color(f'/data/presets/{preset}/top_logo.png', txt_color_hex)
            width, height = logo.size

            # Calculate the new width to maintain the aspect ratio
            new_height = 126
            aspect_ratio = width / height
            new_width = int(new_height * aspect_ratio)

            # Resize the image
            logo = logo.resize((new_width, new_height), Image.Resampling.LANCZOS)
            img.paste(logo, (61, 162), logo)


    if member_name_dropdown:
        img_name = edimg.txt(member_name_dropdown, txt_color_r, txt_color_g, txt_color_b, 130, 0, "l", "font/Helvetica_Neue_LT_Std_65_Medium.otf", (800, 136))
        img.paste(img_name, (54, 466), img_name)

        img_name_side = edimg.txt(member_name_dropdown, txt_color_r, txt_color_g, txt_color_b, 61, 270, "l")
        img.paste(img_name_side, (940, 159), img_name_side)

    if obj_num:
        if obj_alphabet == "Other":
            obj_alphabet = obj_alphabet_txt
        img_obj_num_side = edimg.txt(obj_num+obj_alphabet, txt_color_r,txt_color_g,txt_color_b, 75, 270, "r")
        img.paste(img_obj_num_side, (951, 448), img_obj_num_side)


        if obj_serial:
            img_obj_serial_side = edimg.serial(obj_serial, txt_color_r,txt_color_g,txt_color_b, 75)
            img.paste(img_obj_serial_side, (943, 867), img_obj_serial_side)

    match group_name_radio:
        case "tripleS":
            img_group_name_side = edimg.txt("tripleS", txt_color_r, txt_color_g, txt_color_b, 61, 270, "r")
            img.paste(img_group_name_side, (943, 1238), img_group_name_side)
        case "ARTMS":
            img_group_name_side = edimg.color("resource/artms_side.png", txt_color_hex)
            img.paste(img_group_name_side, (974, 1371), img_group_name_side)
        case "Other":
            img_group_name_side = edimg.txt(group_name_txt, txt_color_r, txt_color_g, txt_color_b, 61, 270, "r")
            img.paste(img_group_name_side, (943, 1238), img_group_name_side)
            group_name_radio = group_name_txt
        case None:
            pass
        case _:


            if os.path.isfile(f'/data/presets/{preset}/sideNameImage.png'):
                sideNameImage = edimg.color(f'/data/presets/{preset}/sideNameImage.png', txt_color_hex)
                sideNameImage.show()
                img.paste(sideNameImage, (951, 1638-sideNameImage.size[1]), sideNameImage)
            else:
                img_group_name = edimg.txt(group_name_radio, txt_color_r, txt_color_g, txt_color_b, 61, 270, "r")
                img.paste(img_group_name, (943, 1238), img_group_name)


            #img_group_name_side = edimg.txt(group_name_radio, txt_color_r, txt_color_g, txt_color_b, 61, 270, "r")
            #img.paste(img_group_name_side, (943, 1238), img_group_name_side)
            group_name_radio = group_name_txt

    match class_radio:
        case "Zero" | "First" | "Double" | "Special" | "Premier":
            img_class = edimg.txt(class_radio, txt_color_r, txt_color_g, txt_color_b, 130, 0, "l", "font/Helvetica_Neue_LT_Std_65_Medium.otf", (800, 136))
            img.paste(img_class, (54, 700), img_class)
        case "Other":
            img_class = edimg.txt(class_txt, txt_color_r, txt_color_g, txt_color_b, 130, 0, "l", "font/Helvetica_Neue_LT_Std_65_Medium.otf", (800, 136))
            img.paste(img_class, (54, 700), img_class)



    match season_radio:
        case "Atom01":
            img_atom01 = edimg.color(atom01, txt_color_hex)
            img.paste(img_atom01, (63, 951), img_atom01)
        case "Binary01":
            img_binary01 = edimg.color(binary01, txt_color_hex)
            img.paste(img_binary01, (63, 951), img_binary01)
        case "Cream01":
            img_cream01 = edimg.color(cream01, txt_color_hex)
            img.paste(img_cream01, (62, 950), img_cream01)
        case "Divine01":
            img_divine01 = edimg.color(divine01, txt_color_hex)
            img.paste(img_divine01, (61, 951), img_divine01)
        case "Ever01":
            img_ever01 = edimg.color(ever01, txt_color_hex)
            img.paste(img_ever01, (61, 951), img_ever01)
        case "Other":
            img_season = edimg.txt(season_txt, txt_color_r, txt_color_g, txt_color_b, 130, 0, "l", "font/Helvetica_Neue_LT_Std_65_Medium.otf", (1100, 136))
            x = edimg.calculate_size(season_txt, 130, "font/Helvetica_Neue_LT_Std_65_Medium.otf")
            img_season_outline = edimg.txt(season_txt_outline, txt_color_r, txt_color_g, txt_color_b, 135, 0, "l", "font/Helvetica_Neue_LT_Std_75_Bold_Outline.otf", (1100, 136))
            img.paste(img_season,(53, 936), img_season)
            img.paste(img_season_outline, (53 + x, 936), img_season_outline)

    if sign in pre.names:
        colored_icon = edimg.color(f'sign/{sign}.png', txt_color_hex)
        position = sign_positions[sign]
        img.paste(colored_icon, position, colored_icon)
    elif sign:
        colored_icon = edimg.color(f'/data/presets/{preset}/{sign}.png', txt_color_hex)
        original_width, original_height = colored_icon.size
        ratio = min(480 / original_width, 330 / original_height)
        new_width = int(original_width * ratio)
        new_height = int(original_height * ratio)
        colored_icon = colored_icon.resize((new_width, new_height), Image.Resampling.LANCZOS)
        img = maker.space(img, (63, 1097), (488, 335), colored_icon)

    if qr_url_dropdown:
        url_txt = fn.url_mapping(qr_url_dropdown)
        img_qr = edimg.qr(url_txt)

        match qr_Logo_radio:
            case "tripleS":
                img_qr_icon = edimg.qr_icon("resource/qr_icon_triples.png")
                img_qr.paste(img_qr_icon, (126, 126), img_qr_icon)
            case 'Cosmo':
                img_qr_icon = edimg.qr_icon("resources/qr_icon_cosmo.png")
                img_qr.paste(img_qr_icon, (126, 126), img_qr_icon)
            case 'None':
                pass
            case _:
                img_qr_icon = Image.open(f'/data/presets/{preset}/qr_logo.png')
                colored_icon = img_qr_icon

                original_width, original_height = colored_icon.size
                ratio = min(84 / original_width, 84 / original_height)
                new_width = int(original_width * ratio)
                new_height = int(original_height * ratio)
                colored_icon = colored_icon.resize((new_width, new_height), Image.Resampling.LANCZOS)

                qr_logo_bg = Image.new(size=(84, 84), mode='RGB', color=(255,255,255))
                qr_logo_bg = maker.space(qr_logo_bg, (0,0), (84,84), colored_icon)

                img_qr.paste(qr_logo_bg, (126, 126))
        img_qr = edimg.resize_img(img_qr, 335,335)
        img.paste(img_qr, (555, 1098))
    else:
        img.paste(img_qr_white_space,(555, 1098))

    if qr_caption:
        qr_caption_img = maker.draw(36, qr_caption, color=txt_color_hex)
        img = maker.space(img, (553, 1453), (339,37), qr_caption_img)


    if right_btn:
        img_right_modhaus = edimg.color(right_modhaus, txt_color_hex)
        img.paste(img_right_modhaus, (61,1604), img_right_modhaus)

    krtime = fn.get_kr_time()
    img_jpeg = img.convert('RGB')
    img_jpeg.save(f'/data/cache/{member_name_dropdown}_{group_name_radio}_{class_radio}_{obj_num}{obj_alphabet}_{krtime}.jpg', quality=90)
    return img, img


make_image_first = Image.open("resource/make_image_first.png")
remove_black = Image.open("resource/remove_black.png")
def ex_gen(img_front, file_front_path, img_back, count, blur, blur_strength, watermark):
    if img_back == None:
        gr.Warning("Make two images, front and back")
        return make_image_first, make_image_first
    if img_front == None and file_front_path == None:
        gr.Warning("Make two images, front and back")
        return  make_image_first, make_image_first
    if file_front_path:
        file_front = Image.open(file_front_path)
        match count:
            case "One File":
                img_back = img_back.resize(file_front.size)
                img_remove_black = remove_black.resize(file_front.size)
                img_back.paste(img_remove_black,(0,0), img_remove_black)
                filename, _ = os.path.splitext(os.path.basename(file_front_path))
                edimg.makegif(file_front, img_back)
                return f"exgif.gif", img_back
            case "Two Files":
                return file_front, img_back
    if blur:
        img_front = img_front.filter(ImageFilter.GaussianBlur(blur_strength))
        img_back = img_back.filter(ImageFilter.GaussianBlur(blur_strength))

    if watermark:
        img_txt = edimg.txt(watermark, 255, 255, 255, 210, 50, "l", "font/Helvetica_Neue_LT_Std_75_Bold.otf",(1338, 222), 120)
        img_front.paste(img_txt, (65, 333), img_txt)
        img_back.paste(img_txt, (65, 333), img_txt)

    match count:
        case "One File":
            img = Image.new("RGBA", (2328, 1800), (0, 0, 0, 0))
            img_front = edimg.rounded(img_front)
            img_back = edimg.rounded(img_back)
            img.paste(img_front, (0, 0), img_front)
            img.paste(img_back, (1164, 0), img_back)
            return img, img_blank
        case "Two Files":
            img_front = edimg.rounded(img_front)
            img_back = edimg.rounded(img_back)
            return img_front, img_back



def find_value(n, percent):
    return n * (percent / 100.0)