Workpam commited on
Commit
29b8bb1
Β·
verified Β·
1 Parent(s): 151726c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -545,6 +545,27 @@ gr.HTML("""
545
  </div>
546
  """)
547
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
548
  with gr.Blocks(css=css) as demo:
549
  # ─── States ───
550
  image_data_state = gr.State([])
@@ -636,7 +657,7 @@ with gr.Blocks(css=css) as demo:
636
  )
637
 
638
  process_btn.click(
639
- fn=lambda mode, sd, ups, pu, fmt, w, h: (
640
  process_url_images(sd, fmt, w, h) if mode.startswith("πŸ“„") and sd else
641
  process_uploaded_images(ups, fmt, w, h) if mode.startswith("πŸ“€") and ups else
642
  process_single_url_image(pu, fmt, w, h) if pu.strip() else
 
545
  </div>
546
  """)
547
 
548
+ def process_all(mode, workbook_file, ups, pu, fmt, w, h):
549
+ # πŸ“„ Workbook mode
550
+ if mode.startswith("πŸ“„"):
551
+ data, msg = read_uploaded_workbook(workbook_file)
552
+ if not data:
553
+ # no links β†’ just show the fetch‑error
554
+ return [], None, msg, None
555
+ # got a list of dicts β†’ process them
556
+ return process_and_zip(data, fmt, w, h)
557
+
558
+ # πŸ“€ Direct image files
559
+ if mode.startswith("πŸ“€") and ups:
560
+ return process_uploaded_images(ups, fmt, w, h)
561
+
562
+ # πŸ”— Single URL
563
+ if pu and pu.strip():
564
+ return process_single_url_image(pu, fmt, w, h)
565
+
566
+ # nothing valid
567
+ return [], None, "⚠️ No valid input provided", None
568
+
569
  with gr.Blocks(css=css) as demo:
570
  # ─── States ───
571
  image_data_state = gr.State([])
 
657
  )
658
 
659
  process_btn.click(
660
+ fn=process_all, sd, ups, pu, fmt, w, h: (
661
  process_url_images(sd, fmt, w, h) if mode.startswith("πŸ“„") and sd else
662
  process_uploaded_images(ups, fmt, w, h) if mode.startswith("πŸ“€") and ups else
663
  process_single_url_image(pu, fmt, w, h) if pu.strip() else