tripleS-Dev commited on
Commit
76f5da6
1 Parent(s): e76c8a3

update V1.3.4L Beta

Browse files
Files changed (3) hide show
  1. fns.py +16 -2
  2. generate.py +6 -0
  3. main.py +25 -1
fns.py CHANGED
@@ -25,13 +25,27 @@ def gif2cache(a):
25
 
26
  def gif_clear():
27
  return
28
- def img2cache_resize(a):
 
29
  krtime = fn.get_kr_time()
30
  a.save(f'/data/cache/original_{krtime}.jpg', quality=90)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  a = edimg.resize_img(a, 1164, 1800)
32
  return a
33
 
34
-
35
  def obj_color_update(obj_color):
36
  if obj_color == "Other color":
37
  return gr.ColorPicker(visible=True), gr.Slider(1, 1000, 0, visible=False), gr.Button(visible=False)
 
25
 
26
  def gif_clear():
27
  return
28
+ def img2cache_resize(a, dummy):
29
+ x, y = a.size
30
  krtime = fn.get_kr_time()
31
  a.save(f'/data/cache/original_{krtime}.jpg', quality=90)
32
+
33
+
34
+ if x <= y:
35
+ a = edimg.resize_img(a, 1164, 1800)
36
+ return a, dummy
37
+ else:
38
+ return a, not dummy
39
+
40
+ def rotate(a):
41
+ if a == None:
42
+ return None
43
+
44
+ a = a.rotate(270, expand=True)
45
+ print('rotated')
46
  a = edimg.resize_img(a, 1164, 1800)
47
  return a
48
 
 
49
  def obj_color_update(obj_color):
50
  if obj_color == "Other color":
51
  return gr.ColorPicker(visible=True), gr.Slider(1, 1000, 0, visible=False), gr.Button(visible=False)
generate.py CHANGED
@@ -19,6 +19,12 @@ side_oma1 = Image.open("resources/side_oma1.png")
19
  side_oma2 = Image.open("resources/side_oma2.png")
20
 
21
  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):
 
 
 
 
 
 
22
  match img_type:
23
  case "Image":
24
  if img_static == None:
 
19
  side_oma2 = Image.open("resources/side_oma2.png")
20
 
21
  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):
22
+
23
+ if not img_static.size == (1164, 1800):
24
+ img_static = edimg.resize_img(img_static, 1164, 1800)
25
+ print('resized!')
26
+
27
+
28
  match img_type:
29
  case "Image":
30
  if img_static == None:
main.py CHANGED
@@ -19,6 +19,20 @@ function refresh() {
19
  }
20
  """
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  theme = gr.themes.Soft(
24
  secondary_hue="violet",
@@ -60,8 +74,18 @@ with gr.Blocks(theme=theme) as demo: # , js=js_func
60
  img_dynamic_show = gr.Image(label="Gif", interactive=False, sources=['upload', 'clipboard'], type="pil", visible=False, scale=10)
61
 
62
 
 
 
 
63
  img_type.change(fn=fns.change_img_type, inputs=[img_type], outputs=[img_static, img_dynamic_file, img_dynamic_show])
64
- img_static.upload(fn=fns.img2cache_resize, inputs=img_static, outputs=img_static)
 
 
 
 
 
 
 
65
  img_dynamic_file.upload(fn=fns.gif2cache, inputs=img_dynamic_file, outputs=img_dynamic_show)
66
  img_dynamic_file.clear(fn=fns.gif_clear, outputs=img_dynamic_show)
67
 
 
19
  }
20
  """
21
 
22
+ confirm_horizontal = "(x) => confirm('Apply horizontal mode?')"
23
+ def rst(a):
24
+ if a == None:
25
+ return False
26
+ return gr.Checkbox()
27
+
28
+ def tests():
29
+ print('tests')
30
+ def chk_size(img, dummy):
31
+ x, y = img.size
32
+ if x <= y:
33
+ return dummy
34
+ else:
35
+ return not dummy
36
 
37
  theme = gr.themes.Soft(
38
  secondary_hue="violet",
 
74
  img_dynamic_show = gr.Image(label="Gif", interactive=False, sources=['upload', 'clipboard'], type="pil", visible=False, scale=10)
75
 
76
 
77
+ horizontal = gr.Checkbox(visible=False, label='horizontal')
78
+ dummy = gr.Checkbox(visible=False, label='dummy')
79
+
80
  img_type.change(fn=fns.change_img_type, inputs=[img_type], outputs=[img_static, img_dynamic_file, img_dynamic_show])
81
+
82
+
83
+ img_static.upload(fn=fns.img2cache_resize, inputs=[img_static, dummy], outputs=[img_static, dummy])
84
+
85
+ img_static.change(fn=rst, inputs=img_static, outputs=[horizontal])
86
+ dummy.change(fn=None, js=confirm_horizontal, outputs=horizontal)
87
+ horizontal.change(fn=fns.rotate, inputs=img_static, outputs=img_static)
88
+
89
  img_dynamic_file.upload(fn=fns.gif2cache, inputs=img_dynamic_file, outputs=img_dynamic_show)
90
  img_dynamic_file.clear(fn=fns.gif_clear, outputs=img_dynamic_show)
91