LPX55 commited on
Commit
d847f85
·
verified ·
1 Parent(s): 54310a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -111,6 +111,7 @@ def prepare_image_and_mask(image, width, height, overlap_percentage, resize_opti
111
  scale_factor = min(target_size[0] / image.width, target_size[1] / image.height)
112
  new_width = int(image.width * scale_factor)
113
  new_height = int(image.height * scale_factor)
 
114
  source = image.resize((new_width, new_height), Image.LANCZOS)
115
 
116
  if resize_option == "Full":
@@ -166,14 +167,17 @@ def prepare_image_and_mask(image, width, height, overlap_percentage, resize_opti
166
  background = Image.new("RGBA", target_size, (255, 255, 255, 255)
167
  else:
168
  background = Image.new("RGB", target_size, (255, 255, 255)
 
 
169
 
170
- background = Image.new('RGB', target_size, (255, 255, 255))
171
  # Paste the source (resized image) onto the background
172
- background.paste(source, (margin_x, margin_y)
 
 
173
 
174
  # Create the generated mask (L mode)
175
  mask = Image.new("L", target_size, 255)
176
-
177
  mask_draw = ImageDraw.Draw(mask)
178
  white_gaps_patch = 2
179
 
 
111
  scale_factor = min(target_size[0] / image.width, target_size[1] / image.height)
112
  new_width = int(image.width * scale_factor)
113
  new_height = int(image.height * scale_factor)
114
+
115
  source = image.resize((new_width, new_height), Image.LANCZOS)
116
 
117
  if resize_option == "Full":
 
167
  background = Image.new("RGBA", target_size, (255, 255, 255, 255)
168
  else:
169
  background = Image.new("RGB", target_size, (255, 255, 255)
170
+
171
+ background.paste(source, (margin_x, margin_y))
172
 
173
+ # background = Image.new('RGB', target_size, (255, 255, 255))
174
  # Paste the source (resized image) onto the background
175
+ # Paste the source image (resized) onto the background
176
+ # If the source has alpha, it will be preserved in the background
177
+
178
 
179
  # Create the generated mask (L mode)
180
  mask = Image.new("L", target_size, 255)
 
181
  mask_draw = ImageDraw.Draw(mask)
182
  white_gaps_patch = 2
183