Spaces:
Running
Running
Upload 6 files
Browse files
edgif.py
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import edimg
|
2 |
+
import numpy as np
|
3 |
+
from PIL import Image, ImageDraw, ImageFont, ImageColor, ImageFilter, ImageSequence
|
4 |
+
import math
|
5 |
+
import shutil
|
6 |
+
|
7 |
+
import fn
|
8 |
+
import fns
|
9 |
+
|
10 |
+
|
11 |
+
def find_smallest_n(x, y):
|
12 |
+
# 97n > x 조건을 만족하는 최소 n 계산
|
13 |
+
n_for_x = math.ceil(x / 97)
|
14 |
+
|
15 |
+
# 150n > y 조건을 만족하는 최소 n 계산
|
16 |
+
n_for_y = math.ceil(y / 150)
|
17 |
+
|
18 |
+
# 두 조건을 모두 만족하는 최소 n
|
19 |
+
n = max(n_for_x, n_for_y)
|
20 |
+
|
21 |
+
return n
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
remove_image_path = 'resource/remove_black.png' # Adjust the path according to your setup
|
28 |
+
remove_img_black = Image.open(remove_image_path).convert("RGBA")
|
29 |
+
|
30 |
+
|
31 |
+
def attach_gif(gif, overlay, chk):
|
32 |
+
# 결과 프레임들을 저장할 리스트
|
33 |
+
frames = []
|
34 |
+
durations = []
|
35 |
+
x, y = gif.size
|
36 |
+
n = find_smallest_n(x, y)
|
37 |
+
target_width = 97 * n
|
38 |
+
target_height = 150 * n
|
39 |
+
overlay = overlay.resize((target_width,target_height), Image.Resampling.LANCZOS)
|
40 |
+
if chk:
|
41 |
+
remove_img = remove_img_black.resize((target_width, target_height), Image.Resampling.BOX)
|
42 |
+
# GIF의 각 프레임을 순회하며 처리합니다.
|
43 |
+
|
44 |
+
for frame in ImageSequence.Iterator(gif):
|
45 |
+
|
46 |
+
durations.append(frame.info['duration'])
|
47 |
+
# PNG 이미지를 GIF 프레임과 같은 크기로 조정합니다.
|
48 |
+
# 이 부분은 필요에 따라 조정할 수 있습니다
|
49 |
+
|
50 |
+
resized_frame = frame.copy()
|
51 |
+
img = resized_frame
|
52 |
+
|
53 |
+
# 원본 이미지의 크기와 비율 계산
|
54 |
+
original_width, original_height = img.size
|
55 |
+
ratio = min(original_width / target_width, original_height / target_height)
|
56 |
+
|
57 |
+
# 새로운 크기 계산
|
58 |
+
new_width = int(target_width * ratio)
|
59 |
+
new_height = int(target_height * ratio)
|
60 |
+
|
61 |
+
# 이미지를 중앙에서 자름
|
62 |
+
img = img.crop(((original_width - new_width) // 2,
|
63 |
+
(original_height - new_height) // 2,
|
64 |
+
(original_width + new_width) // 2,
|
65 |
+
(original_height + new_height) // 2))
|
66 |
+
|
67 |
+
# 최종적으로 목표 해상도로 리사이즈
|
68 |
+
img = img.resize((target_width, target_height), Image.Resampling.LANCZOS)
|
69 |
+
img.paste(overlay, (0, 0), overlay)
|
70 |
+
if chk:
|
71 |
+
img.paste(remove_img, (0, 0), remove_img)
|
72 |
+
|
73 |
+
frame = img.quantize(method=2)
|
74 |
+
# 두 이미지를 합칩니다.
|
75 |
+
#combined = Image.alpha_composite(frame.convert('RGBA'), overlay)
|
76 |
+
|
77 |
+
# 결과 리스트에 추가합니다.
|
78 |
+
frames.append(img)
|
79 |
+
|
80 |
+
# 모든 프레임을 처리한 후, 새로운 GIF로 저장합니다.
|
81 |
+
frames[1].save('output.gif', save_all=True, append_images=frames[1:], loop=0, duration=durations, disposal=0, optimize=True)
|
82 |
+
krtime = fn.get_kr_time()
|
83 |
+
shutil.copy2("output.gif", f"/data/cache/{krtime}.gif")
|
84 |
+
|
85 |
+
|
edimg.py
ADDED
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from PIL import Image, ImageDraw, ImageFont, ImageColor, ImageFilter, ImageSequence
|
2 |
+
import numpy as np
|
3 |
+
import qrcode
|
4 |
+
|
5 |
+
def paste_img(img, img2, coordinate):
|
6 |
+
if not isinstance(img, Image.Image):
|
7 |
+
img = Image.open(img).convert("RGBA")
|
8 |
+
|
9 |
+
if not isinstance(img2, Image.Image):
|
10 |
+
img2 = Image.open(img2).convert("RGBA")
|
11 |
+
|
12 |
+
img.paste(img2, coordinate, img2)
|
13 |
+
|
14 |
+
return img
|
15 |
+
|
16 |
+
def color(img, color):
|
17 |
+
if not isinstance(img, Image.Image):
|
18 |
+
img = Image.open(img).convert("RGBA")
|
19 |
+
image_np = np.array(img)
|
20 |
+
_, _, _, alpha = image_np.T
|
21 |
+
mask = alpha > 0
|
22 |
+
image_np[..., :-1][mask.T] = ImageColor.getcolor(color, "RGB")
|
23 |
+
img = Image.fromarray(image_np)
|
24 |
+
return img
|
25 |
+
|
26 |
+
def txt(text, r, g, b, font, angle, rl, fonts = "font/Helvetica_Neue_LT_Std_75_Bold.otf", image_size = (400, 100), opacity = 255):
|
27 |
+
# 이미지 크기와 글꼴 크기 설정
|
28 |
+
font_size = font
|
29 |
+
|
30 |
+
# 이미지와 드로잉 객체 생성
|
31 |
+
image = Image.new('RGBA', image_size, (255, 255, 255, 0)) # 투명한 배경
|
32 |
+
draw = ImageDraw.Draw(image)
|
33 |
+
|
34 |
+
# 글꼴 설정
|
35 |
+
font = ImageFont.truetype(fonts, font_size)
|
36 |
+
text_color = (r, g, b, opacity)
|
37 |
+
|
38 |
+
# 텍스트 그리기
|
39 |
+
text_bbox = draw.textbbox((0, 0), text, font=font)
|
40 |
+
text_width = text_bbox[2] - text_bbox[0]
|
41 |
+
text_height = text_bbox[3] - text_bbox[1]
|
42 |
+
match rl:
|
43 |
+
case "r":
|
44 |
+
text_x = image_size[0] - text_width # 오른쪽 정렬을 위해 수정
|
45 |
+
text_y = (image_size[1] - text_height) / 2
|
46 |
+
draw.text((text_x, text_y), text, fill=text_color, font=font)
|
47 |
+
case "l":
|
48 |
+
# 텍스트를 왼쪽으로 정렬하여 그리기
|
49 |
+
text_x = 0 # 왼쪽 맞춤
|
50 |
+
text_y = (image_size[1] - text_height) / 2
|
51 |
+
draw.text((text_x, text_y), text, fill=text_color, font=font)
|
52 |
+
# 이미지 회전
|
53 |
+
if angle != 0:
|
54 |
+
image = image.rotate(angle, expand=True)
|
55 |
+
return image
|
56 |
+
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
+
def serial(text, r, g, b, font_size):
|
61 |
+
# 이미지 크기와 글꼴 크기 설정
|
62 |
+
text = "#"+ text
|
63 |
+
image_size = (400, 100) # 너비 x 높이
|
64 |
+
fonts = "font/MatrixSSK Regular.ttf"
|
65 |
+
spacing = 43 # 글자 간 간격
|
66 |
+
|
67 |
+
# 이미지와 드로잉 객체 생성
|
68 |
+
image = Image.new('RGBA', image_size, (255, 255, 255, 0)) # 투명한 배경
|
69 |
+
draw = ImageDraw.Draw(image)
|
70 |
+
|
71 |
+
# 글꼴 설정
|
72 |
+
font = ImageFont.truetype(fonts, font_size)
|
73 |
+
text_color = (r, g, b)
|
74 |
+
|
75 |
+
# 텍스트 위치 초기화
|
76 |
+
current_x = 0
|
77 |
+
text_y = (image_size[1] - font_size) // 2 # 세로 중앙 정렬
|
78 |
+
|
79 |
+
# 각 글자를 개별적으로 그리기
|
80 |
+
for char in text:
|
81 |
+
draw.text((current_x, text_y), char, fill=text_color, font=font)
|
82 |
+
current_x += spacing
|
83 |
+
|
84 |
+
# 이미지 회전
|
85 |
+
rotated_image = image.rotate(270, expand=True)
|
86 |
+
|
87 |
+
return rotated_image
|
88 |
+
|
89 |
+
|
90 |
+
remove_image_path = f'resource/ai_remove.png' # Adjust the path according to your setup
|
91 |
+
remove_img = Image.open(remove_image_path).convert("RGBA")
|
92 |
+
remove_np = np.array(remove_img)
|
93 |
+
|
94 |
+
# remove.png에서 r 채널이 255이고 알파 채널이 있는 픽셀 위치 찾기
|
95 |
+
r_channel = remove_np[:, :, 0]
|
96 |
+
alpha_channel = remove_np[:, :, 3]
|
97 |
+
mask = (r_channel == 255) & (alpha_channel > 0)
|
98 |
+
|
99 |
+
|
100 |
+
def color_ai(num):
|
101 |
+
grimg = Image.open(f'grad2/gradient_{num}.png')
|
102 |
+
# resized_image를 RGBA 형식으로 변환 (필요한 경우에만)
|
103 |
+
grimg = grimg.convert("RGBA")
|
104 |
+
grimg_np = np.array(grimg)
|
105 |
+
|
106 |
+
# 해당 위치의 resized_image 픽셀을 투명하게 설정
|
107 |
+
grimg_np[mask, :] = (0, 0, 0, 0) # RGBA 형식에 맞게 조정
|
108 |
+
|
109 |
+
grimg = Image.fromarray(grimg_np)
|
110 |
+
return grimg
|
111 |
+
|
112 |
+
def color_ai_back(num):
|
113 |
+
file_path = f'grad2/gradient_{num}.png'
|
114 |
+
img = Image.open(file_path)
|
115 |
+
# 잘라낼 부분 설정 (x < 126에 해당하는 부분)
|
116 |
+
left = 125
|
117 |
+
top = 0
|
118 |
+
right = 1289 # x가 126보다 작은 부분까지
|
119 |
+
bottom = 1800
|
120 |
+
|
121 |
+
# 이미지 자르기
|
122 |
+
cropped_img = img.crop((left, top, right, bottom))
|
123 |
+
return cropped_img
|
124 |
+
|
125 |
+
|
126 |
+
remove_image_path_rounded = 'resource/remove.png' # Adjust the path according to your setup
|
127 |
+
remove_img_rounded = Image.open(remove_image_path_rounded).convert("RGBA")
|
128 |
+
remove_np_rounded = np.array(remove_img_rounded)
|
129 |
+
|
130 |
+
# remove.png에서 r 채널이 255이고 알파 채널이 있는 픽셀 위치 찾기
|
131 |
+
|
132 |
+
r_channel_rounded = remove_np_rounded[:, :, 0]
|
133 |
+
alpha_channel_rounded = remove_np_rounded[:, :, 3]
|
134 |
+
mask_rounded = (r_channel_rounded == 255) & (alpha_channel_rounded > 0)
|
135 |
+
def rounded(img):
|
136 |
+
img = img.convert("RGBA")
|
137 |
+
img_np = np.array(img)
|
138 |
+
|
139 |
+
# 해당 위치의 resized_image 픽셀을 투명하게 설정
|
140 |
+
img_np[mask_rounded, :] = (0, 0, 0, 0) # RGBA 형식에 맞게 조정
|
141 |
+
|
142 |
+
img = Image.fromarray(img_np)
|
143 |
+
return img
|
144 |
+
|
145 |
+
|
146 |
+
|
147 |
+
def resize_img(image, target_width, target_height):
|
148 |
+
if not isinstance(image, Image.Image):
|
149 |
+
img = Image.open(image).convert("RGBA")
|
150 |
+
|
151 |
+
else:
|
152 |
+
img = image
|
153 |
+
# 원본 이미지의 크기와 비율 계산
|
154 |
+
original_width, original_height = img.size
|
155 |
+
ratio = min(original_width / target_width, original_height / target_height)
|
156 |
+
|
157 |
+
# 새로운 크기 계산
|
158 |
+
new_width = int(target_width * ratio)
|
159 |
+
new_height = int(target_height * ratio)
|
160 |
+
|
161 |
+
# 이미지를 중앙에서 자름
|
162 |
+
img = img.crop(((original_width - new_width) // 2,
|
163 |
+
(original_height - new_height) // 2,
|
164 |
+
(original_width + new_width) // 2,
|
165 |
+
(original_height + new_height) // 2))
|
166 |
+
|
167 |
+
# 최종적으로 목표 해상도로 리사이즈
|
168 |
+
img = img.resize((target_width, target_height), Image.Resampling.LANCZOS)
|
169 |
+
|
170 |
+
return img
|
171 |
+
|
172 |
+
|
173 |
+
def calculate_size(text, font_size, font_path):
|
174 |
+
# Create a dummy image just to create a draw object
|
175 |
+
dummy_image = Image.new('RGB', (1100, 136))
|
176 |
+
draw = ImageDraw.Draw(dummy_image)
|
177 |
+
|
178 |
+
# Load the font
|
179 |
+
font = ImageFont.truetype(font_path, font_size)
|
180 |
+
|
181 |
+
# Calculate text width using the defined draw object
|
182 |
+
text_width = draw.textlength(text, font=font)
|
183 |
+
|
184 |
+
return int(text_width)
|
185 |
+
|
186 |
+
|
187 |
+
|
188 |
+
def qr(url):
|
189 |
+
# Generate QR code with a smaller border
|
190 |
+
qr = qrcode.QRCode(
|
191 |
+
version=1,
|
192 |
+
error_correction=qrcode.constants.ERROR_CORRECT_H,
|
193 |
+
box_size=10,
|
194 |
+
border=2, # Reduce the border by the border_reduction amount
|
195 |
+
)
|
196 |
+
qr.add_data(url)
|
197 |
+
qr.make(fit=True)
|
198 |
+
|
199 |
+
# Create an image from the QR Code instance
|
200 |
+
qr_img = qr.make_image(fill_color="black", back_color="white").convert('RGB')
|
201 |
+
|
202 |
+
qr_img = qr_img.resize((335,335), Image.Resampling.LANCZOS)
|
203 |
+
|
204 |
+
return qr_img
|
205 |
+
|
206 |
+
|
207 |
+
def qr_icon(icon_path):
|
208 |
+
img_icon = Image.open(icon_path)
|
209 |
+
img_icon = resize_img(img_icon, 84,84)
|
210 |
+
return img_icon
|
211 |
+
|
212 |
+
|
213 |
+
|
214 |
+
def makegif(gif, back):
|
215 |
+
# 결과 프레임들을 저장할 리스트
|
216 |
+
frames = []
|
217 |
+
durations = []
|
218 |
+
x, y = gif.size
|
219 |
+
|
220 |
+
|
221 |
+
# GIF의 각 프레임을 순회하며 처리합니다.
|
222 |
+
for frame in ImageSequence.Iterator(gif):
|
223 |
+
durations.append(frame.info['duration'])
|
224 |
+
img = Image.new("RGB", (2 * x, y))
|
225 |
+
img.paste(frame, (0,0))
|
226 |
+
|
227 |
+
# 두 이미지를 합칩니다.
|
228 |
+
img.paste(back, (x,0))
|
229 |
+
|
230 |
+
# 결과 리스트에 추가합니다.
|
231 |
+
frames.append(img)
|
232 |
+
|
233 |
+
# 모든 프레임을 처리한 후, 새로운 GIF로 저장합니다.
|
234 |
+
frames[1].save(f'exgif.gif', save_all=True, append_images=frames[1:], loop=0, duration=durations, disposal=0, optimize=True)
|
fn.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datetime import datetime
|
2 |
+
import pytz
|
3 |
+
import os
|
4 |
+
import shutil
|
5 |
+
|
6 |
+
|
7 |
+
|
8 |
+
def hex_to_rgb(hex_color):
|
9 |
+
# Remove the '#' character if it exists
|
10 |
+
hex_color = hex_color.lstrip('#')
|
11 |
+
|
12 |
+
# Convert the hex string to integers
|
13 |
+
r, g, b = tuple(int(hex_color[i:i + 2], 16) for i in (0, 2, 4))
|
14 |
+
return r, g, b
|
15 |
+
|
16 |
+
|
17 |
+
def get_kr_time():
|
18 |
+
# 한국 시간대 설정
|
19 |
+
korea_time_zone = pytz.timezone('Asia/Seoul')
|
20 |
+
|
21 |
+
# 현재 시간을 한국 시간대로 변환
|
22 |
+
current_time_in_korea = datetime.now(korea_time_zone)
|
23 |
+
|
24 |
+
# 원하는 형식으로 시간 포맷팅
|
25 |
+
return current_time_in_korea.strftime("%Y%m%d-%H%M%S")
|
26 |
+
|
27 |
+
def url_mapping(url):
|
28 |
+
# 각 문자열에 대응하는 URL 매핑
|
29 |
+
url_mapping = {
|
30 |
+
"tripleS website": "https://triplescosmos.com/",
|
31 |
+
"tripleS youtube": "https://youtube.com/@triplescosmos",
|
32 |
+
"tripleS 𝕏": "https://x.com/triplescosmos",
|
33 |
+
"tripleS discord": "https://discord.gg/triplescosmos"
|
34 |
+
}
|
35 |
+
|
36 |
+
# qr_url이 매핑된 문자열 중 하나라면 해당 URL을, 아니라면 qr_url 그대로를 반환
|
37 |
+
return url_mapping.get(url, url)
|
38 |
+
|
39 |
+
|
40 |
+
def zip(name):
|
41 |
+
# '/data' 폴더를 'data.zip'으로 압축
|
42 |
+
shutil.make_archive(f'/data/{name}', 'zip', f'/data/{name}')
|
43 |
+
shutil.rmtree(f'/data/{name}')
|
44 |
+
|
45 |
+
def remove(filename):
|
46 |
+
# './data/' 디렉터리 경로 설정
|
47 |
+
directory = '/data/'
|
48 |
+
|
49 |
+
file_path = os.path.join(directory, filename)
|
50 |
+
# 파일이 zip 파일인지 확인
|
51 |
+
if filename.endswith('.zip'):
|
52 |
+
# 파일 삭제
|
53 |
+
os.remove(file_path)
|
fns.py
ADDED
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import random
|
3 |
+
import shutil
|
4 |
+
import fn
|
5 |
+
import edimg
|
6 |
+
import os
|
7 |
+
|
8 |
+
|
9 |
+
def change_img_type(a):
|
10 |
+
if a == "Image":
|
11 |
+
return gr.File(visible=True), gr.Image(visible=False), gr.Image(visible=False)
|
12 |
+
else:
|
13 |
+
return gr.File(visible=False), gr.Image(visible=True), gr.Image(visible=True)
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
def gif2cache(a):
|
18 |
+
krtime = fn.get_kr_time()
|
19 |
+
shutil.copy2(a, f'/data/cache/original_{krtime}.gif')
|
20 |
+
return a
|
21 |
+
|
22 |
+
def gif_clear():
|
23 |
+
return
|
24 |
+
def img2cache_resize(a):
|
25 |
+
krtime = fn.get_kr_time()
|
26 |
+
a.save(f'/data/cache/original_{krtime}.jpg', quality=90)
|
27 |
+
a = edimg.resize_img(a, 1164, 1800)
|
28 |
+
return a
|
29 |
+
|
30 |
+
|
31 |
+
def obj_color_update(obj_color):
|
32 |
+
if obj_color == "Other color":
|
33 |
+
return gr.ColorPicker(visible=True), gr.Slider(1, 1000, 0, visible=False), gr.Button(visible=False)
|
34 |
+
elif obj_color == "AI Color":
|
35 |
+
ran = random.randrange(1, 1000)
|
36 |
+
return gr.ColorPicker(visible=False), gr.Slider(1, 1000, ran, visible=True), gr.Button(visible=True)
|
37 |
+
else:
|
38 |
+
return gr.ColorPicker(visible=False), gr.Slider(1, 1000, 0, visible=False), gr.Button(visible=False)
|
39 |
+
|
40 |
+
|
41 |
+
def txt_color_update(txt_color_picker):
|
42 |
+
if txt_color_picker == "Other":
|
43 |
+
return gr.Image(visible=True)
|
44 |
+
else:
|
45 |
+
return gr.Image(visible=False)
|
46 |
+
|
47 |
+
|
48 |
+
|
49 |
+
def group_member_name_update(a):
|
50 |
+
if a == "Other":
|
51 |
+
return gr.Textbox(visible=True), gr.Dropdown([], label="Name", allow_custom_value=True)
|
52 |
+
elif a == "tripleS":
|
53 |
+
return gr.Textbox(visible=False), gr.Dropdown(
|
54 |
+
["SeoYeon", "HyeRin", "JiWoo", "ChaeYeon", "YooYeon", "SooMin", "NaKyoung", "YuBin", "Kaede", "DaHyun",
|
55 |
+
"Kotone", "YeonJi", "Nien", "SoHyun", "Xinyu", "Mayu", "Lynn", "JooBin", "HaYeon", "ShiOn", "ChaeWon", "Sullin", "SeoAh", "JiYeon"], label="Name",
|
56 |
+
allow_custom_value=True)
|
57 |
+
elif a == "ARTMS":
|
58 |
+
return gr.Textbox(visible=False), gr.Dropdown(["HeeJin", "JinSoul", "Kim Lip", "Choerry", "HaSeul"],
|
59 |
+
label="Name", allow_custom_value=True)
|
60 |
+
|
61 |
+
|
62 |
+
def alphabet_txt_update(a):
|
63 |
+
if a == "Other":
|
64 |
+
return gr.Textbox(visible=True)
|
65 |
+
else:
|
66 |
+
return gr.Textbox(visible=False)
|
67 |
+
|
68 |
+
|
69 |
+
def serial_random():
|
70 |
+
ran1 = random.randrange(0, 9)
|
71 |
+
ran2 = random.randrange(0, 9)
|
72 |
+
ran3 = random.randrange(0, 9)
|
73 |
+
ran4 = random.randrange(0, 9)
|
74 |
+
ran5 = random.randrange(0, 9)
|
75 |
+
return gr.Textbox(value=f"{ran1}{ran2}{ran3}{ran4}{ran5}")
|
76 |
+
|
77 |
+
def frame_color_update(a):
|
78 |
+
if a == "Other":
|
79 |
+
return gr.ColorPicker(visible=True)
|
80 |
+
else:
|
81 |
+
return gr.ColorPicker(visible=False)
|
82 |
+
|
83 |
+
|
84 |
+
|
85 |
+
def ex_gen_count(a):
|
86 |
+
if a == "Two Files":
|
87 |
+
return gr.Image(visible=True)
|
88 |
+
else:
|
89 |
+
return gr.Image(visible=False)
|
90 |
+
|
91 |
+
|
92 |
+
|
93 |
+
def rounded_sync(a):
|
94 |
+
return gr.Checkbox(value=a)
|
95 |
+
|
96 |
+
|
97 |
+
def ex_blur(a):
|
98 |
+
if a:
|
99 |
+
return gr.Slider(interactive=True)
|
100 |
+
else:
|
101 |
+
return gr.Slider(interactive=False)
|
102 |
+
|
103 |
+
|
104 |
+
|
105 |
+
def refresh():
|
106 |
+
directory_path = "/data"
|
107 |
+
# directory_path 내의 항목들을 리스트로 가져옴
|
108 |
+
items = os.listdir(directory_path)
|
109 |
+
# 해당 항목이 디렉토리인지 확인 후, 특정 폴더를 제외한 폴더 이름만 필터링
|
110 |
+
folders = [item for item in items]
|
111 |
+
folders_tuple = tuple(folders)
|
112 |
+
|
113 |
+
# 현재 작업 디렉토리의 폴더 이름들을 튜플로 반환 (특정 폴더 제외)
|
114 |
+
return folders_tuple
|
115 |
+
|
116 |
+
def dev(a):
|
117 |
+
if a == "Whitehasthewrongonememberwhoisnotavailabletoyoursetupandthechoicesaregiveneveryyearforcharandcroptoyoursetupicontomakethechangesyouareusing":
|
118 |
+
folders = refresh()
|
119 |
+
return "Do", gr.Dropdown(folders, visible=True, interactive=True), gr.File(visible=True, interactive=True), gr.Button(visible=True, interactive=True), gr.Button(visible=True, interactive=True), gr.Button(visible=True, interactive=True), gr.Button(visible=True, interactive=True)
|
120 |
+
elif a == "Whitehasthewrongonememberwhoisnotavailabletoyoursetupandthechoicesaregiveneveryyearforcharandcroptoyoursetupicontomakethechangesyouareusingmake":
|
121 |
+
os.makedirs("/data/cache")
|
122 |
+
return "Permission denied", gr.Dropdown(visible=False, interactive=False), gr.File(visible=False, interactive=False), gr.Button(visible=False, interactive=False), gr.Button(visible=False, interactive=False), gr.Button(visible=False, interactive=False), gr.Button(visible=False, interactive=False)
|
123 |
+
else:
|
124 |
+
return "Permission denied", gr.Dropdown(visible=False, interactive=False), gr.File(visible=False, interactive=False), gr.Button(visible=False, interactive=False), gr.Button(visible=False, interactive=False), gr.Button(visible=False, interactive=False), gr.Button(visible=False, interactive=False)
|
125 |
+
|
126 |
+
|
127 |
+
def dev2():
|
128 |
+
time = fn.get_kr_time()
|
129 |
+
os.rename("/data/cache", f"/data/{time}")
|
130 |
+
os.mkdir("/data/cache")
|
131 |
+
return "Moved"
|
132 |
+
|
133 |
+
def dev3(a):
|
134 |
+
|
135 |
+
fn.zip(a)
|
136 |
+
return f"/data/{a}"
|
137 |
+
|
138 |
+
|
139 |
+
def dev4(a):
|
140 |
+
return f"/data/{a}"
|
141 |
+
|
142 |
+
def dev5(a):
|
143 |
+
fn.remove(a)
|
144 |
+
return "Deleted"
|
145 |
+
|
146 |
+
|
147 |
+
def txt_season_visibility(a):
|
148 |
+
if a == "Other":
|
149 |
+
return gr.Textbox(visible=True), gr.Textbox(visible=True)
|
150 |
+
else:
|
151 |
+
return gr.Textbox(visible=False), gr.Textbox(visible=False)
|
152 |
+
|
153 |
+
|
154 |
+
|
155 |
+
def change_ran(a):
|
156 |
+
if a == "AI Color":
|
157 |
+
ran = random.randrange(1, 1000)
|
158 |
+
return ran
|
159 |
+
else:
|
160 |
+
return 0
|
161 |
+
|
162 |
+
|
163 |
+
|
164 |
+
def txt_class_visibility(a):
|
165 |
+
if a == "Other":
|
166 |
+
return gr.Textbox(visible=True)
|
167 |
+
else:
|
168 |
+
return gr.Textbox(visible=False)
|
169 |
+
|
generate.py
ADDED
@@ -0,0 +1,356 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
import gradio as gr
|
6 |
+
import fn
|
7 |
+
import edimg
|
8 |
+
import edgif
|
9 |
+
from PIL import Image, ImageDraw, ImageFont, ImageColor, ImageFilter, ImageSequence
|
10 |
+
|
11 |
+
|
12 |
+
img_blank = Image.open('resource/blank.png')
|
13 |
+
|
14 |
+
|
15 |
+
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, rounded):
|
16 |
+
match img_type:
|
17 |
+
case "Image":
|
18 |
+
if img_static == None:
|
19 |
+
gr.Warning("Upload the image first")
|
20 |
+
return "resource/upload_first.png", "resource/upload_first.png", None
|
21 |
+
img = 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, rounded)
|
22 |
+
return img, img, None
|
23 |
+
case "Gif":
|
24 |
+
if img_dynamic_file == None:
|
25 |
+
gr.Warning("Upload the gif first")
|
26 |
+
return "resource/upload_first.png", "resource/upload_first.png", None
|
27 |
+
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, rounded)
|
28 |
+
gif = Image.open(img_dynamic_file)
|
29 |
+
edgif.attach_gif(gif, overlay, rounded)
|
30 |
+
return "output.gif", "output.gif", "output.gif"
|
31 |
+
|
32 |
+
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, rounded):
|
33 |
+
|
34 |
+
match obj_color:
|
35 |
+
case "Atom01":
|
36 |
+
obj_color = "#ffdd00"
|
37 |
+
front_side = edimg.color("resource/front_side.png", obj_color)
|
38 |
+
img.paste(front_side, (0, 0), front_side)
|
39 |
+
case "Binary01":
|
40 |
+
obj_color = "#00ff01"
|
41 |
+
front_side = edimg.color("resource/front_side.png", obj_color)
|
42 |
+
img.paste(front_side, (0, 0), front_side)
|
43 |
+
case "Cream01":
|
44 |
+
obj_color = "#ff7477"
|
45 |
+
front_side = edimg.color("resource/front_side.png", obj_color)
|
46 |
+
img.paste(front_side, (0, 0), front_side)
|
47 |
+
case "Divine01":
|
48 |
+
obj_color = "#a226f5"
|
49 |
+
front_side = edimg.color("resource/front_side.png", obj_color)
|
50 |
+
img.paste(front_side, (0, 0), front_side)
|
51 |
+
case "Special":
|
52 |
+
img = edimg.paste_img(img, "resource/special_side.png", (0, 0))
|
53 |
+
case "Other color":
|
54 |
+
obj_color = obj_color_picker
|
55 |
+
front_side = edimg.color("resource/front_side.png", obj_color)
|
56 |
+
img.paste(front_side, (0, 0), front_side)
|
57 |
+
case "AI Color":
|
58 |
+
front_side = edimg.color_ai(ai_num)
|
59 |
+
img.paste(front_side, (1038, 0), front_side)
|
60 |
+
|
61 |
+
|
62 |
+
match txt_color:
|
63 |
+
case "White":
|
64 |
+
txt_color_r = 255
|
65 |
+
txt_color_g = 255
|
66 |
+
txt_color_b = 255
|
67 |
+
txt_color_hex = "#FFFFFF"
|
68 |
+
case "Black":
|
69 |
+
txt_color_r = 0
|
70 |
+
txt_color_g = 0
|
71 |
+
txt_color_b = 0
|
72 |
+
txt_color_hex = "#000000"
|
73 |
+
case _:
|
74 |
+
txt_color_r, txt_color_g, txt_color_b = fn.hex_to_rgb(txt_color_picker)
|
75 |
+
txt_color_hex = txt_color_picker
|
76 |
+
|
77 |
+
|
78 |
+
if member_name_dropdown:
|
79 |
+
img_name = edimg.txt(member_name_dropdown, txt_color_r, txt_color_g, txt_color_b, 61, 270, "l")
|
80 |
+
img.paste(img_name, (1050, 161), img_name)
|
81 |
+
|
82 |
+
match group_name_radio:
|
83 |
+
case "tripleS":
|
84 |
+
img_group_name = edimg.txt(group_name_radio, txt_color_r, txt_color_g, txt_color_b, 61, 270, "r")
|
85 |
+
img.paste(img_group_name, (1050, 1240), img_group_name)
|
86 |
+
case "ARTMS":
|
87 |
+
img_artms_side = edimg.color("resource/artms_side.png", txt_color_hex)
|
88 |
+
img.paste(img_artms_side, (1081, 1371), img_artms_side)
|
89 |
+
|
90 |
+
case "Other":
|
91 |
+
img_group_name = edimg.txt(group_name_txt, txt_color_r, txt_color_g, txt_color_b, 61, 270, "r")
|
92 |
+
img.paste(img_group_name, (1050, 1240), img_group_name)
|
93 |
+
|
94 |
+
if obj_num != "" and obj_alphabet != "":
|
95 |
+
if obj_alphabet == "Other":
|
96 |
+
obj_alphabet = obj_alphabet_txt
|
97 |
+
img_obj_num = edimg.txt(obj_num+obj_alphabet, txt_color_r, txt_color_g, txt_color_b, 75, 270, "r")
|
98 |
+
img.paste(img_obj_num, (1050, 452), img_obj_num)
|
99 |
+
|
100 |
+
if obj_serial:
|
101 |
+
img_serial = edimg.serial(obj_serial, txt_color_r, txt_color_g, txt_color_b, 75)
|
102 |
+
img.paste(img_serial, (1046, 871), img_serial)
|
103 |
+
if rounded:
|
104 |
+
img = edimg.rounded(img)
|
105 |
+
|
106 |
+
krtime = fn.get_kr_time()
|
107 |
+
img_jpeg = img.convert('RGB')
|
108 |
+
img_jpeg.save(f'/data/cache/{member_name_dropdown}_{group_name_radio}_{obj_num}{obj_alphabet}_{krtime}.jpg', quality=90)
|
109 |
+
return img
|
110 |
+
|
111 |
+
back_ui = Image.open("resource/back_ui.png")
|
112 |
+
outline_ui = Image.open("resource/outline.png")
|
113 |
+
|
114 |
+
|
115 |
+
sign_positions = {
|
116 |
+
1: (31, 1068),
|
117 |
+
2: (0, 1103),
|
118 |
+
3: (34, 1101),
|
119 |
+
4: (1, 1053),
|
120 |
+
5: (79, 1100),
|
121 |
+
6: (0, 1057),
|
122 |
+
7: (0, 1116),
|
123 |
+
8: (20, 1109),
|
124 |
+
9: (26, 1109),
|
125 |
+
10: (42, 1104),
|
126 |
+
11: (31, 1105),
|
127 |
+
12: (0, 1065),
|
128 |
+
13: (58, 1108),
|
129 |
+
14: (0, 1110),
|
130 |
+
15: (0, 1105),
|
131 |
+
16: (49, 1056),
|
132 |
+
17: (61, 1105),
|
133 |
+
18: (84, 1118),
|
134 |
+
19: (39, 1167),
|
135 |
+
20: (170, 1105),
|
136 |
+
21: (64, 1124),
|
137 |
+
22: (41, 1146),
|
138 |
+
23: (52, 1113),
|
139 |
+
24: (65, 1129),
|
140 |
+
|
141 |
+
25: (38, 1148),
|
142 |
+
26: (61, 1100),
|
143 |
+
27: (52, 1113),
|
144 |
+
28: (46, 1022),
|
145 |
+
29: (62, 1131)
|
146 |
+
}
|
147 |
+
|
148 |
+
cream01 = Image.open("resource/cream01.png")
|
149 |
+
atom01 = Image.open("resource/atom01.png")
|
150 |
+
binary01 = Image.open("resource/binary01.png")
|
151 |
+
divine01 = Image.open("resource/divine01.png")
|
152 |
+
|
153 |
+
right_modhaus = Image.open("resource/right_modhaus.png")
|
154 |
+
img_qr_white_space = Image.new("RGB", (335, 335), 'white')
|
155 |
+
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, rounded_back):
|
156 |
+
match obj_outline_color:
|
157 |
+
case "White":
|
158 |
+
outline = edimg.color(outline_ui, "#FFFFFF")
|
159 |
+
case "Black":
|
160 |
+
outline = edimg.color(outline_ui, "#000000")
|
161 |
+
case _:
|
162 |
+
outline = edimg.color(outline_ui, obj_outline_color_picker)
|
163 |
+
|
164 |
+
|
165 |
+
|
166 |
+
match obj_color:
|
167 |
+
case "Atom01":
|
168 |
+
obj_color = "#ffdd00"
|
169 |
+
img = Image.new("RGB", (1164, 1800), obj_color)
|
170 |
+
case "Binary01":
|
171 |
+
obj_color = "#00ff01"
|
172 |
+
img = Image.new("RGB", (1164, 1800), obj_color)
|
173 |
+
case "Cream01":
|
174 |
+
obj_color = "#ff7477"
|
175 |
+
img = Image.new("RGB", (1164, 1800), obj_color)
|
176 |
+
case "Divine01":
|
177 |
+
obj_color = "#a226f5"
|
178 |
+
img = Image.new("RGB", (1164, 1800), obj_color)
|
179 |
+
case "Special":
|
180 |
+
img = Image.open('resource/special_back.png')
|
181 |
+
case "Other color":
|
182 |
+
obj_color = obj_color_picker
|
183 |
+
img = Image.new("RGB", (1164, 1800), obj_color)
|
184 |
+
case "AI Color":
|
185 |
+
img = edimg.color_ai_back(ai_num)
|
186 |
+
case _:
|
187 |
+
img = Image.new("RGB", (1164, 1800), "#FFFFFF")
|
188 |
+
|
189 |
+
img.paste(outline, (0,0), outline)
|
190 |
+
|
191 |
+
match txt_color:
|
192 |
+
case "White":
|
193 |
+
txt_color_r = 255
|
194 |
+
txt_color_g = 255
|
195 |
+
txt_color_b = 255
|
196 |
+
txt_color_hex = "#FFFFFF"
|
197 |
+
case "Black":
|
198 |
+
txt_color_r = 0
|
199 |
+
txt_color_g = 0
|
200 |
+
txt_color_b = 0
|
201 |
+
txt_color_hex = "#000000"
|
202 |
+
case _:
|
203 |
+
txt_color_r, txt_color_g, txt_color_b = fn.hex_to_rgb(txt_color_picker)
|
204 |
+
txt_color_hex = txt_color_picker
|
205 |
+
|
206 |
+
back_ui_colored = edimg.color(back_ui, txt_color_hex)
|
207 |
+
img.paste(back_ui_colored, (0, 0), back_ui_colored)
|
208 |
+
|
209 |
+
|
210 |
+
match logo_radio:
|
211 |
+
case "tripleS":
|
212 |
+
logo = edimg.color('resource/triples_logo.png', txt_color_hex)
|
213 |
+
img.paste(logo, (61, 162), logo)
|
214 |
+
case "ARTMS":
|
215 |
+
logo = edimg.color('resource/artms_logo.png', txt_color_hex)
|
216 |
+
img.paste(logo, (61, 162), logo)
|
217 |
+
|
218 |
+
|
219 |
+
if member_name_dropdown:
|
220 |
+
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))
|
221 |
+
img.paste(img_name, (54, 466), img_name)
|
222 |
+
|
223 |
+
img_name_side = edimg.txt(member_name_dropdown, txt_color_r, txt_color_g, txt_color_b, 61, 270, "l")
|
224 |
+
img.paste(img_name_side, (932, 159),img_name_side)
|
225 |
+
|
226 |
+
if obj_num:
|
227 |
+
if obj_alphabet == "Other":
|
228 |
+
obj_alphabet = obj_alphabet_txt
|
229 |
+
img_obj_num_side = edimg.txt(obj_num+obj_alphabet, txt_color_r,txt_color_g,txt_color_b, 75, 270, "r")
|
230 |
+
img.paste(img_obj_num_side, (951, 448), img_obj_num_side)
|
231 |
+
|
232 |
+
|
233 |
+
if obj_serial:
|
234 |
+
img_obj_serial_side = edimg.serial(obj_serial, txt_color_r,txt_color_g,txt_color_b, 75)
|
235 |
+
img.paste(img_obj_serial_side, (943, 867), img_obj_serial_side)
|
236 |
+
|
237 |
+
match group_name_radio:
|
238 |
+
case "tripleS":
|
239 |
+
img_group_name_side = edimg.txt("tripleS", txt_color_r, txt_color_g, txt_color_b, 61, 270, "r")
|
240 |
+
img.paste(img_group_name_side, (943, 1238), img_group_name_side)
|
241 |
+
case "ARTMS":
|
242 |
+
img_group_name_side = edimg.color("resource/artms_side.png", txt_color_hex)
|
243 |
+
img.paste(img_group_name_side, (974, 1371), img_group_name_side)
|
244 |
+
case "Other":
|
245 |
+
img_group_name_side = edimg.txt(group_name_txt, txt_color_r, txt_color_g, txt_color_b, 61, 270, "r")
|
246 |
+
img.paste(img_group_name_side, (943, 1238), img_group_name_side)
|
247 |
+
group_name_radio = group_name_txt
|
248 |
+
|
249 |
+
match class_radio:
|
250 |
+
case "Zero" | "First" | "Double" | "Special":
|
251 |
+
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))
|
252 |
+
img.paste(img_class, (54, 700), img_class)
|
253 |
+
case "Other":
|
254 |
+
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))
|
255 |
+
img.paste(img_class, (54, 700), img_class)
|
256 |
+
|
257 |
+
|
258 |
+
|
259 |
+
match season_radio:
|
260 |
+
case "Atom01":
|
261 |
+
img_atom01 = edimg.color(atom01, txt_color_hex)
|
262 |
+
img.paste(img_atom01, (63, 951), img_atom01)
|
263 |
+
case "Binary01":
|
264 |
+
img_binary01 = edimg.color(binary01, txt_color_hex)
|
265 |
+
img.paste(img_binary01, (63, 951), img_binary01)
|
266 |
+
case "Cream01":
|
267 |
+
img_cream01 = edimg.color(cream01, txt_color_hex)
|
268 |
+
img.paste(img_cream01, (62, 950), img_cream01)
|
269 |
+
case "Divine01":
|
270 |
+
img_divine01 = edimg.color(divine01, txt_color_hex)
|
271 |
+
img.paste(img_divine01, (61, 951), img_divine01)
|
272 |
+
case "Other":
|
273 |
+
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))
|
274 |
+
x = edimg.calculate_size(season_txt, 130, "font/Helvetica_Neue_LT_Std_65_Medium.otf")
|
275 |
+
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))
|
276 |
+
img.paste(img_season,(53, 936), img_season)
|
277 |
+
img.paste(img_season_outline, (53 + x, 936), img_season_outline)
|
278 |
+
|
279 |
+
if sign != None:
|
280 |
+
sign = sign + 1
|
281 |
+
colored_icon = edimg.color(f'sign/{sign}.png', txt_color_hex)
|
282 |
+
if sign in sign_positions:
|
283 |
+
position = sign_positions[sign]
|
284 |
+
img.paste(colored_icon, position, colored_icon)
|
285 |
+
|
286 |
+
|
287 |
+
if qr_url_dropdown:
|
288 |
+
url_txt = fn.url_mapping(qr_url_dropdown)
|
289 |
+
img_qr = edimg.qr(url_txt)
|
290 |
+
|
291 |
+
match qr_Logo_radio:
|
292 |
+
case "tripleS":
|
293 |
+
img_qr_icon = edimg.qr_icon("resource/qr_icon_triples.png")
|
294 |
+
img_qr.paste(img_qr_icon, (126, 126), img_qr_icon)
|
295 |
+
|
296 |
+
img_qr = edimg.resize_img(img_qr, 335,335)
|
297 |
+
img.paste(img_qr, (555, 1098))
|
298 |
+
else:
|
299 |
+
img.paste(img_qr_white_space,(555, 1098))
|
300 |
+
|
301 |
+
if right_btn:
|
302 |
+
img_right_modhaus = edimg.color(right_modhaus, txt_color_hex)
|
303 |
+
img.paste(img_right_modhaus, (61,1604), img_right_modhaus)
|
304 |
+
|
305 |
+
if rounded_back:
|
306 |
+
img = edimg.rounded(img)
|
307 |
+
|
308 |
+
krtime = fn.get_kr_time()
|
309 |
+
img_jpeg = img.convert('RGB')
|
310 |
+
img_jpeg.save(f'/data/cache/{member_name_dropdown}_{group_name_radio}_{class_radio}_{obj_num}{obj_alphabet}_{krtime}.jpg', quality=90)
|
311 |
+
return img, img
|
312 |
+
|
313 |
+
|
314 |
+
make_image_first = Image.open("resource/make_image_first.png")
|
315 |
+
remove_black = Image.open("resource/remove_black.png")
|
316 |
+
def ex_gen(img_front, file_front_path, img_back, count, blur, blur_strength, watermark):
|
317 |
+
if img_back == None:
|
318 |
+
gr.Warning("Make two images, front and back")
|
319 |
+
return make_image_first, make_image_first
|
320 |
+
if img_front == None and file_front_path == None:
|
321 |
+
gr.Warning("Make two images, front and back")
|
322 |
+
return make_image_first, make_image_first
|
323 |
+
if file_front_path:
|
324 |
+
file_front = Image.open(file_front_path)
|
325 |
+
match count:
|
326 |
+
case "One File":
|
327 |
+
img_back = img_back.resize(file_front.size)
|
328 |
+
img_remove_black = remove_black.resize(file_front.size)
|
329 |
+
img_back.paste(img_remove_black,(0,0), img_remove_black)
|
330 |
+
filename, _ = os.path.splitext(os.path.basename(file_front_path))
|
331 |
+
edimg.makegif(file_front, img_back)
|
332 |
+
return f"exgif.gif", img_back
|
333 |
+
case "Two Files":
|
334 |
+
return file_front, img_back
|
335 |
+
if blur:
|
336 |
+
img_front = img_front.filter(ImageFilter.GaussianBlur(blur_strength))
|
337 |
+
img_back = img_back.filter(ImageFilter.GaussianBlur(blur_strength))
|
338 |
+
|
339 |
+
if watermark:
|
340 |
+
img_txt = edimg.txt(watermark, 255, 255, 255, 210, 50, "l", "font/Helvetica_Neue_LT_Std_75_Bold.otf",(1338, 222), 120)
|
341 |
+
img_front.paste(img_txt, (65, 333), img_txt)
|
342 |
+
img_back.paste(img_txt, (65, 333), img_txt)
|
343 |
+
|
344 |
+
match count:
|
345 |
+
case "One File":
|
346 |
+
img = Image.new("RGBA", (2328, 1800), (0, 0, 0, 0))
|
347 |
+
img_front = edimg.rounded(img_front)
|
348 |
+
img_back = edimg.rounded(img_back)
|
349 |
+
img.paste(img_front, (0, 0), img_front)
|
350 |
+
img.paste(img_back, (1164, 0), img_back)
|
351 |
+
return img, img_blank
|
352 |
+
case "Two Files":
|
353 |
+
img_front = edimg.rounded(img_front)
|
354 |
+
img_back = edimg.rounded(img_back)
|
355 |
+
return img_front, img_back
|
356 |
+
|
main.py
ADDED
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import fns
|
3 |
+
import generate
|
4 |
+
|
5 |
+
|
6 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
7 |
+
with gr.Row():
|
8 |
+
gr.Markdown(
|
9 |
+
"""
|
10 |
+
# Custom Objekt
|
11 |
+
## Input image and Select Options
|
12 |
+
""")
|
13 |
+
|
14 |
+
with gr.Tab("Front"):
|
15 |
+
with gr.Row():
|
16 |
+
with gr.Column(): #1
|
17 |
+
img_type = gr.Radio(["Image", "Gif"], value="Image", scale=1, label="type")
|
18 |
+
img_static = gr.Image(label="Image", interactive=True, sources=['upload', 'clipboard'], type="pil", visible=True, scale=10)
|
19 |
+
img_dynamic_file = gr.File(file_types=[".gif"], visible=False, scale=1, interactive=True, label="Gif File", type="filepath")
|
20 |
+
img_dynamic_show = gr.Image(label="Gif", interactive=False, sources=['upload', 'clipboard'], type="pil", visible=False, scale=10)
|
21 |
+
|
22 |
+
|
23 |
+
img_type.change(fn=fns.change_img_type, inputs=[img_type], outputs=[img_static, img_dynamic_file, img_dynamic_show])
|
24 |
+
img_static.upload(fn=fns.img2cache_resize, inputs=img_static, outputs=img_static)
|
25 |
+
img_dynamic_file.upload(fn=fns.gif2cache, inputs=img_dynamic_file, outputs=img_dynamic_show)
|
26 |
+
img_dynamic_file.clear(fn=fns.gif_clear, outputs=img_dynamic_show)
|
27 |
+
|
28 |
+
|
29 |
+
with gr.Column(): #2
|
30 |
+
with gr.Group(): #objekt color
|
31 |
+
obj_color = gr.Radio(["Atom01", "Binary01", "Cream01", "Divine01", "Special", "Other color", "AI Color"], label="Objekt Color", value="Cream01")
|
32 |
+
|
33 |
+
with gr.Row():
|
34 |
+
ai_num = gr.Slider(1, 1000, 500, label="AI Serial", visible=False, step=1)
|
35 |
+
change_ai = gr.Button(value="Change AI", visible=False)
|
36 |
+
obj_color_picker = gr.ColorPicker(label="Other Objekt Color", visible=False, interactive=True, value="#ffffff")
|
37 |
+
|
38 |
+
|
39 |
+
obj_color.change(fn=fns.obj_color_update, inputs=obj_color, outputs=[obj_color_picker, ai_num, change_ai])
|
40 |
+
|
41 |
+
|
42 |
+
with gr.Group():
|
43 |
+
txt_color = gr.Radio(["White", "Black", "Other"], label="Text Color", value="Black")
|
44 |
+
txt_color_picker = gr.ColorPicker(label="Other Text Color", value="#ffffff", visible=False, interactive=True)
|
45 |
+
txt_color.change(fns.txt_color_update, txt_color, txt_color_picker)
|
46 |
+
with gr.Group():
|
47 |
+
group_name_radio = gr.Radio(["tripleS", "ARTMS", "Other"], label="Group Name")
|
48 |
+
group_name_txt = gr.Textbox(label="Other Group name", placeholder="CLASSY", visible=False, interactive=True)
|
49 |
+
|
50 |
+
with gr.Group():
|
51 |
+
member_name_dropdown = gr.Dropdown(
|
52 |
+
["SeoYeon", "HyeRin", "JiWoo", "ChaeYeon", "YooYeon", "SooMin", "NaKyoung", "YuBin", "Kaede",
|
53 |
+
"DaHyun", "Kotone", "YeonJi", "Nien", "SoHyun", "Xinyu", "Mayu", "Lynn", "JooBin", "HaYeon",
|
54 |
+
"ShiOn", "ChaeWon", "Sullin", "SeoAh", "JiYeon"], label="Member Name", allow_custom_value=True)
|
55 |
+
|
56 |
+
group_name_radio.change(fns.group_member_name_update, group_name_radio, [group_name_txt, member_name_dropdown])
|
57 |
+
|
58 |
+
|
59 |
+
with gr.Accordion("Add Objekt Number", open=False):
|
60 |
+
with gr.Row():
|
61 |
+
obj_num = gr.Textbox(label="Objekt Number", placeholder="100", interactive=True, visible=True, scale=1)
|
62 |
+
obj_alphabet = gr.Radio(["Z", "A", "Other"], label="Z or A", interactive=True, visible=True, scale=1)
|
63 |
+
obj_alphabet_txt = gr.Textbox(label="Alphabet", placeholder="S", interactive=True, visible=False, scale=1)
|
64 |
+
|
65 |
+
obj_alphabet.change(fns.alphabet_txt_update, obj_alphabet, obj_alphabet_txt)
|
66 |
+
|
67 |
+
|
68 |
+
with gr.Row():
|
69 |
+
obj_serial = gr.Textbox(label="Objekt Serial", placeholder="00001", interactive=True, visible=True, scale=1)
|
70 |
+
obj_serial_random = gr.Button(value="Random Serial", interactive=True, visible=True, scale=1)
|
71 |
+
|
72 |
+
|
73 |
+
obj_serial_random.click(fn=fns.serial_random, outputs=obj_serial)
|
74 |
+
|
75 |
+
|
76 |
+
with gr.Group():
|
77 |
+
rounded = gr.Checkbox(label="Rounded", value=True, interactive=True)
|
78 |
+
with gr.Group():
|
79 |
+
generate_btn = gr.Button(value="Generate")
|
80 |
+
|
81 |
+
with gr.Column():
|
82 |
+
edited_img = gr.Image(label="Edited Image", scale=10)
|
83 |
+
|
84 |
+
|
85 |
+
with gr.Tab("Back") as back_tab:
|
86 |
+
with gr.Row():
|
87 |
+
preview = gr.Image(label="Image", interactive=False)
|
88 |
+
with gr.Column():
|
89 |
+
with gr.Group():
|
90 |
+
obj_outline_color = gr.Radio(["White", "Black", "Other"], label="Frame color", value="White")
|
91 |
+
obj_outline_color_picker = gr.ColorPicker(label="Other Outline Color", value="#ffffff", visible=False, interactive=True)
|
92 |
+
|
93 |
+
obj_outline_color.change(fns.frame_color_update, obj_outline_color, obj_outline_color_picker)
|
94 |
+
|
95 |
+
with gr.Group():
|
96 |
+
logo_radio = gr.Radio(["tripleS", "ARTMS", "None"], label="Add Logo", interactive=True, value="None")
|
97 |
+
|
98 |
+
|
99 |
+
with gr.Group():
|
100 |
+
class_radio = gr.Radio(["Zero", "First", "Double", "Special", "Other"], label="CLASS", visible=True)
|
101 |
+
class_txt = gr.Textbox(label="Other class", placeholder="Third", visible=False)
|
102 |
+
|
103 |
+
class_radio.change(fns.txt_class_visibility, class_radio, class_txt)
|
104 |
+
|
105 |
+
with gr.Group():
|
106 |
+
season_radio = gr.Radio(["Atom01", "Binary01", "Cream01", "Divine01", "Other"], label="SEASON", type="value")
|
107 |
+
|
108 |
+
with gr.Row():
|
109 |
+
season_txt = gr.Textbox(label="Other SEASON", interactive=True, visible=False)
|
110 |
+
season_txt_outline = gr.Textbox(label="Other SEASON Outline", interactive=True, visible=False)
|
111 |
+
|
112 |
+
season_radio.change(fns.txt_season_visibility, season_radio, [season_txt, season_txt_outline])
|
113 |
+
|
114 |
+
with gr.Group():
|
115 |
+
sign = gr.Dropdown(
|
116 |
+
["SeoYeon", "HyeRin", "JiWoo", "ChaeYeon", "YooYeon", "SooMin", "NaKyoung", "YuBin", "Kaede",
|
117 |
+
"DaHyun", "Kotone", "YeonJi", "Nien", "SoHyun", "Xinyu", "Mayu", "Lynn", "JooBin", "HaYeon",
|
118 |
+
"ShiOn", "ChaeWon", "Sullin", "SeoAh", "JiYeon", "HeeJin", "KimLip", "JinSoul", "Choerry", "HaSeul"], label="Sign", type='index')
|
119 |
+
with gr.Group():
|
120 |
+
qr_url_dropdown = gr.Dropdown(["tripleS website", "tripleS youtube", "tripleS 𝕏", "tripleS discord"],
|
121 |
+
label="qr url", info="Can write any url", allow_custom_value=True)
|
122 |
+
with gr.Row():
|
123 |
+
qr_Logo_radio = gr.Radio(["tripleS", "None"], label="tripleS Logo", value="None",
|
124 |
+
interactive=True)
|
125 |
+
with gr.Group():
|
126 |
+
right_btn = gr.Checkbox(label="Add Rights", value=False, interactive=True)
|
127 |
+
with gr.Group():
|
128 |
+
rounded_back = gr.Checkbox(label="Rounded", value=True, interactive=True)
|
129 |
+
with gr.Group():
|
130 |
+
generate_btn_back = gr.Button(value="Generate")
|
131 |
+
|
132 |
+
with gr.Column():
|
133 |
+
outputs2 = gr.Image(label="Edited Image", scale=10)
|
134 |
+
|
135 |
+
with gr.Tab("Export") as ex:
|
136 |
+
with gr.Row():
|
137 |
+
ex_img_f = gr.Image(label="Front", type="pil", interactive=False)
|
138 |
+
ex_file_f = gr.File(render=True, visible=False)
|
139 |
+
ex_img_b = gr.Image(label="Back", type="pil", interactive=False)
|
140 |
+
with gr.Column():
|
141 |
+
with gr.Group():
|
142 |
+
with gr.Row():
|
143 |
+
ex_hide_blur = gr.Checkbox(label="Blur")
|
144 |
+
ex_hide_blur_range = gr.Slider(1, 20, 5, label="Blur Range", step=1, interactive=False, scale=10)
|
145 |
+
|
146 |
+
ex_hide_blur.select(fns.ex_blur, ex_hide_blur, ex_hide_blur_range)
|
147 |
+
|
148 |
+
with gr.Group():
|
149 |
+
watermark = gr.Textbox(label="Add watermark")
|
150 |
+
|
151 |
+
ex_gen_file_count = gr.Radio(["One File", "Two Files"], label="Export Type", value="One File")
|
152 |
+
ex_btn = gr.Button(value="Export")
|
153 |
+
with gr.Row():
|
154 |
+
ex_img_f_out = gr.Image(label="Front", interactive=False)
|
155 |
+
ex_img_b_out = gr.Image(label="Back", visible=False, interactive=False)
|
156 |
+
|
157 |
+
|
158 |
+
|
159 |
+
with gr.Tab("Dev"):
|
160 |
+
dev_txt = gr.Textbox(label="Developer Key", visible=True, interactive=True)
|
161 |
+
dev_btn = gr.Button(value="Do and refresh", visible=True, interactive=True)
|
162 |
+
dev_out = gr.Textbox()
|
163 |
+
dev_drop = gr.Dropdown(visible=False, interactive=False)
|
164 |
+
dev_file = gr.File(visible=False, interactive=False)
|
165 |
+
dev_btn2 = gr.Button(visible=False, interactive=False, value="move")
|
166 |
+
dev_btn3 = gr.Button(visible=False, interactive=False, value="zip")
|
167 |
+
dev_btn4 = gr.Button(visible=False, interactive=False, value="download")
|
168 |
+
dev_btn5 = gr.Button(visible=False, interactive=False, value="remove")
|
169 |
+
|
170 |
+
dev_btn2.click(fn=fns.dev2, outputs=dev_out)
|
171 |
+
dev_btn3.click(fn=fns.dev3, inputs=dev_drop, outputs=dev_out)
|
172 |
+
dev_btn4.click(fn=fns.dev4, inputs=dev_drop, outputs=dev_file)
|
173 |
+
dev_btn5.click(fn=fns.dev5, inputs=dev_drop, outputs=dev_out)
|
174 |
+
dev_btn.click(fns.dev, dev_txt, [dev_out, dev_drop, dev_file, dev_btn2, dev_btn3, dev_btn4, dev_btn5])
|
175 |
+
gr.Markdown(
|
176 |
+
"""
|
177 |
+
## Made by
|
178 |
+
# Discord : hj_sss (Can DM)
|
179 |
+
# Cosmo : ILoveYouyeon
|
180 |
+
### this site is free But I hope anyone can support the objekt to my Cosmo
|
181 |
+
""")
|
182 |
+
|
183 |
+
generate_btn.click(fn=generate.sorting,
|
184 |
+
inputs=[img_type, img_static, img_dynamic_file, obj_color, obj_color_picker, ai_num, txt_color,
|
185 |
+
txt_color_picker, member_name_dropdown, group_name_radio, group_name_txt, obj_num,
|
186 |
+
obj_alphabet, obj_alphabet_txt, obj_serial, rounded], outputs=[edited_img, ex_img_f, ex_file_f])
|
187 |
+
|
188 |
+
ex_gen_file_count.change(fns.ex_gen_count, ex_gen_file_count, ex_img_b_out)
|
189 |
+
rounded.change(fns.rounded_sync, rounded, rounded_back)
|
190 |
+
rounded_back.change(fns.rounded_sync, rounded_back, rounded)
|
191 |
+
|
192 |
+
change_ai.click(fns.change_ran, obj_color, ai_num)
|
193 |
+
|
194 |
+
generate_btn_back.click(fn=generate.back,
|
195 |
+
inputs=[obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group_name_radio,
|
196 |
+
group_name_txt, member_name_dropdown, obj_num, obj_alphabet, obj_alphabet_txt,
|
197 |
+
obj_serial, obj_outline_color, obj_outline_color_picker, logo_radio, class_radio,
|
198 |
+
class_txt, season_radio, season_txt, season_txt_outline, sign, qr_url_dropdown,
|
199 |
+
qr_Logo_radio, right_btn, rounded_back], outputs=[outputs2, ex_img_b])
|
200 |
+
|
201 |
+
back_tab.select(fn=generate.back,
|
202 |
+
inputs=[obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group_name_radio,
|
203 |
+
group_name_txt, member_name_dropdown, obj_num, obj_alphabet, obj_alphabet_txt, obj_serial,
|
204 |
+
obj_outline_color, obj_outline_color_picker, logo_radio, class_radio, class_txt,
|
205 |
+
season_radio, season_txt, season_txt_outline, sign, qr_url_dropdown, qr_Logo_radio,
|
206 |
+
right_btn, rounded_back], outputs=[preview, ex_img_b])
|
207 |
+
|
208 |
+
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])
|
209 |
+
|
210 |
+
if __name__ == "__main__":
|
211 |
+
print("http://localhost:7860")
|
212 |
+
demo.launch(server_name="0.0.0.0")
|
213 |
+
|