KingNish commited on
Commit
7038e45
·
verified ·
1 Parent(s): dfffe13

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -66,18 +66,18 @@ def calculate_new_dimensions(orig_w, orig_h):
66
  """
67
  Calculates new dimensions for height and width based on original media dimensions.
68
  Rules:
69
- 1. If any dimension > 1024, resize so max dimension is 1024, maintaining aspect ratio.
70
  2. Then ensure both dimensions are multiples of 32 by rounding to the nearest multiple.
71
- 3. Ensure dimensions are within [256, 1024].
72
  """
73
  if orig_w == 0 or orig_h == 0:
74
  return TARGET_FIXED_SIDE, TARGET_FIXED_SIDE
75
 
76
  # Step 1: Handle dimensions > 1024
77
  new_w, new_h = orig_w, orig_h
78
- if max(orig_w, orig_h) > 1024:
79
  max_dim = max(orig_w, orig_h)
80
- scale = 1024 / max_dim
81
  new_w = int(orig_w * scale)
82
  new_h = int(orig_h * scale)
83
 
 
66
  """
67
  Calculates new dimensions for height and width based on original media dimensions.
68
  Rules:
69
+ 1. If any dimension > MAX_IMAGE_SIZE, resize so max dimension is MAX_IMAGE_SIZE, maintaining aspect ratio.
70
  2. Then ensure both dimensions are multiples of 32 by rounding to the nearest multiple.
71
+ 3. Ensure dimensions are within [256, MAX_IMAGE_SIZE].
72
  """
73
  if orig_w == 0 or orig_h == 0:
74
  return TARGET_FIXED_SIDE, TARGET_FIXED_SIDE
75
 
76
  # Step 1: Handle dimensions > 1024
77
  new_w, new_h = orig_w, orig_h
78
+ if max(orig_w, orig_h) > MAX_IMAGE_SIZE:
79
  max_dim = max(orig_w, orig_h)
80
+ scale = MAX_IMAGE_SIZE / max_dim
81
  new_w = int(orig_w * scale)
82
  new_h = int(orig_h * scale)
83