155elkhorn commited on
Commit
6f654f0
·
1 Parent(s): a20a37c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -47,6 +47,10 @@ def resize_and_overlay_image(input_image, reduction_percentage, shift_percentage
47
  shift_x = int(width * shift_percentage_lr / 100)
48
  shift_y = int(height * shift_percentage_ud / 100)
49
 
 
 
 
 
50
  # Resize the cropped image while maintaining aspect ratio
51
  aspect_ratio = width / height
52
  if new_width / new_height > aspect_ratio:
@@ -57,13 +61,9 @@ def resize_and_overlay_image(input_image, reduction_percentage, shift_percentage
57
  resized_height = int(new_width / aspect_ratio)
58
  resized_img = cv2.resize(cropped_img, (resized_width, resized_height))
59
 
60
- # Create a new background image with the original image dimensions and specified color
61
- background_rgb = hex_to_rgb(background_color)
62
- background_img = np.ones((height, width, 3), dtype=np.uint8) * background_rgb
63
-
64
  # Calculate the position to overlay the resized image on the background image
65
  x = int((width - resized_width) / 2) + shift_x
66
- y = shift_y
67
 
68
  # Overlay the resized image on the background image
69
  background_img[y:y + resized_height, x:x + resized_width] = resized_img
 
47
  shift_x = int(width * shift_percentage_lr / 100)
48
  shift_y = int(height * shift_percentage_ud / 100)
49
 
50
+ # Create a new background image with the same dimensions as the input image and specified color
51
+ background_rgb = hex_to_rgb(background_color)
52
+ background_img = np.ones_like(img) * background_rgb
53
+
54
  # Resize the cropped image while maintaining aspect ratio
55
  aspect_ratio = width / height
56
  if new_width / new_height > aspect_ratio:
 
61
  resized_height = int(new_width / aspect_ratio)
62
  resized_img = cv2.resize(cropped_img, (resized_width, resized_height))
63
 
 
 
 
 
64
  # Calculate the position to overlay the resized image on the background image
65
  x = int((width - resized_width) / 2) + shift_x
66
+ y = int((height - resized_height) / 2) + shift_y
67
 
68
  # Overlay the resized image on the background image
69
  background_img[y:y + resized_height, x:x + resized_width] = resized_img