Preeeeet commited on
Commit
1991892
·
verified ·
1 Parent(s): d07bfcf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -23
app.py CHANGED
@@ -45,32 +45,32 @@ def process_images(images, job_number, job_name, job_address):
45
  run_job.font.color.rgb = RGBColor(0, 0, 0) # Set font color to black
46
 
47
  uploaded_date = datetime.now().strftime("%Y-%m-%d")
48
-
49
- # Create a 2x2 table layout for images
50
- table = doc.add_table(rows=2, cols=2)
51
- table.autofit = True
52
 
53
- for i, img_file in enumerate(images):
54
- row = i // 2
55
- col = i % 2
 
 
 
 
 
 
 
56
 
57
- taken_date = get_image_creation_date(img_file)
58
- uploaded_by = get_image_owner(img_file) or "Unknown"
 
59
 
60
- cell = table.cell(row, col)
61
- run = cell.paragraphs[0].add_run()
62
- run.add_picture(img_file, width=Inches(2.5)) # Resize to fit
63
-
64
- # Add metadata below the image
65
- for text in [
66
- "Description: Describe it here!",
67
- f"Taken Date: {taken_date}",
68
- f"Uploaded By: {uploaded_by}",
69
- f"Uploaded Date: {uploaded_date}",
70
- f"File Name: {os.path.basename(img_file)}"
71
- ]:
72
- paragraph = cell.add_paragraph(text)
73
- paragraph.style.font.name = "Arial"
74
 
75
  # Save the document
76
  output_path = "/tmp/HKC_report_output.docx"
 
45
  run_job.font.color.rgb = RGBColor(0, 0, 0) # Set font color to black
46
 
47
  uploaded_date = datetime.now().strftime("%Y-%m-%d")
 
 
 
 
48
 
49
+ # Create 2x2 tables to hold 4 images per table
50
+ for i in range(0, len(images), 4):
51
+ table = doc.add_table(rows=2, cols=2)
52
+ table.autofit = True
53
+ for j, img_file in enumerate(images[i:i+4]):
54
+ row = j // 2
55
+ col = j % 2
56
+
57
+ taken_date = get_image_creation_date(img_file)
58
+ uploaded_by = get_image_owner(img_file) or "Unknown"
59
 
60
+ cell = table.cell(row, col)
61
+ run = cell.paragraphs[0].add_run()
62
+ run.add_picture(img_file, width=Inches(2.5)) # Resize to fit
63
 
64
+ # Add metadata below the image
65
+ for text in [
66
+ "Description: Describe it here!",
67
+ f"Taken Date: {taken_date}",
68
+ f"Uploaded By: {uploaded_by}",
69
+ f"Uploaded Date: {uploaded_date}",
70
+ f"File Name: {os.path.basename(img_file)}"
71
+ ]:
72
+ paragraph = cell.add_paragraph(text)
73
+ paragraph.style.font.name = "Arial"
 
 
 
 
74
 
75
  # Save the document
76
  output_path = "/tmp/HKC_report_output.docx"