jbilcke commited on
Commit
e7e705d
·
1 Parent(s): 355629c

testing something

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -428,10 +428,13 @@ def get_image_size_for_position(position_data, image_index, num_images, max_reso
428
  return max_resolution, max_resolution # Default square
429
 
430
  x_rel, y_rel, w_rel, h_rel = position_data
431
-
432
  # Calculate the EXACT aspect ratio from the layout rectangle
433
  # This is crucial - we must match this aspect ratio precisely
434
- layout_aspect_ratio = w_rel / h_rel if h_rel > 0 else 1.0
 
 
 
435
 
436
  # Scale to max_resolution while maintaining EXACT aspect ratio
437
  if layout_aspect_ratio >= 1: # Wider than tall
 
428
  return max_resolution, max_resolution # Default square
429
 
430
  x_rel, y_rel, w_rel, h_rel = position_data
431
+
432
  # Calculate the EXACT aspect ratio from the layout rectangle
433
  # This is crucial - we must match this aspect ratio precisely
434
+ # A4 page dimensions in points (must match PDF generation)
435
+ page_width, page_height = 595.27, 841.89
436
+ # Account for the page's aspect ratio when calculating layout aspect ratio
437
+ layout_aspect_ratio = (w_rel / h_rel) * (page_width / page_height) if h_rel > 0 else 1.0
438
 
439
  # Scale to max_resolution while maintaining EXACT aspect ratio
440
  if layout_aspect_ratio >= 1: # Wider than tall