updated PDF report metadata
Browse files- S2FApp/app.py +13 -0
S2FApp/app.py
CHANGED
|
@@ -171,6 +171,7 @@ def _heatmap_to_png_bytes(scaled_heatmap, colormap_name="Jet"):
|
|
| 171 |
|
| 172 |
def _create_pdf_report(img, scaled_heatmap, pixel_sum, force, force_scale, base_name, colormap_name="Jet"):
|
| 173 |
"""Create a PDF report with input image, heatmap, and metrics."""
|
|
|
|
| 174 |
from reportlab.lib.pagesizes import A4
|
| 175 |
from reportlab.lib.units import inch
|
| 176 |
from reportlab.pdfgen import canvas
|
|
@@ -178,9 +179,21 @@ def _create_pdf_report(img, scaled_heatmap, pixel_sum, force, force_scale, base_
|
|
| 178 |
|
| 179 |
buf = io.BytesIO()
|
| 180 |
c = canvas.Canvas(buf, pagesize=A4)
|
|
|
|
|
|
|
| 181 |
w, h = A4
|
| 182 |
img_w, img_h = 2.5 * inch, 2.5 * inch
|
| 183 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
# Images first (drawn lower so title can go on top)
|
| 185 |
img_top = h - 70
|
| 186 |
img_pil = Image.fromarray(img) if img.ndim == 2 else Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
|
|
|
|
| 171 |
|
| 172 |
def _create_pdf_report(img, scaled_heatmap, pixel_sum, force, force_scale, base_name, colormap_name="Jet"):
|
| 173 |
"""Create a PDF report with input image, heatmap, and metrics."""
|
| 174 |
+
from datetime import datetime
|
| 175 |
from reportlab.lib.pagesizes import A4
|
| 176 |
from reportlab.lib.units import inch
|
| 177 |
from reportlab.pdfgen import canvas
|
|
|
|
| 179 |
|
| 180 |
buf = io.BytesIO()
|
| 181 |
c = canvas.Canvas(buf, pagesize=A4)
|
| 182 |
+
c.setTitle("Shape2Force")
|
| 183 |
+
c.setAuthor("Angione-Lab")
|
| 184 |
w, h = A4
|
| 185 |
img_w, img_h = 2.5 * inch, 2.5 * inch
|
| 186 |
|
| 187 |
+
# Footer area (reserve space at bottom)
|
| 188 |
+
footer_y = 40
|
| 189 |
+
c.setFont("Helvetica", 8)
|
| 190 |
+
c.setFillColorRGB(0.4, 0.4, 0.4)
|
| 191 |
+
gen_date = datetime.now().strftime("%Y-%m-%d %H:%M")
|
| 192 |
+
c.drawString(72, footer_y, f"Generated by Shape2Force (S2F) on {gen_date}")
|
| 193 |
+
c.drawString(72, footer_y - 12, "Model: https://huggingface.co/Angione-Lab/Shape2Force")
|
| 194 |
+
c.drawString(72, footer_y - 24, "Web app: https://huggingface.co/spaces/Angione-Lab/Shape2force")
|
| 195 |
+
c.setFillColorRGB(0, 0, 0)
|
| 196 |
+
|
| 197 |
# Images first (drawn lower so title can go on top)
|
| 198 |
img_top = h - 70
|
| 199 |
img_pil = Image.fromarray(img) if img.ndim == 2 else Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
|