gaur3009 commited on
Commit
716f6d9
·
verified ·
1 Parent(s): eb3ffe1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -47,11 +47,12 @@ def fit_and_warp_design(image_a, image_b, top_left_x, top_left_y, bottom_right_x
47
  # Resize the design to fit within the specified bounding box
48
  design_width = bottom_right[0] - top_left[0]
49
  design_height = bottom_right[1] - top_left[1]
 
50
  image_b = image_b.resize((design_width, design_height))
51
 
52
  # Create a blank canvas with the same size as Image-A
53
  canvas = Image.new('RGBA', (displacement_map.shape[1], displacement_map.shape[0]), (0, 0, 0, 0))
54
- canvas.paste(image_b, top_left, image_b)
55
  canvas_np = np.array(canvas)
56
 
57
  h, w = displacement_map.shape
 
47
  # Resize the design to fit within the specified bounding box
48
  design_width = bottom_right[0] - top_left[0]
49
  design_height = bottom_right[1] - top_left[1]
50
+ image_b = image_b.convert("RGBA") # Ensure design image has an alpha channel
51
  image_b = image_b.resize((design_width, design_height))
52
 
53
  # Create a blank canvas with the same size as Image-A
54
  canvas = Image.new('RGBA', (displacement_map.shape[1], displacement_map.shape[0]), (0, 0, 0, 0))
55
+ canvas.paste(image_b, top_left, image_b) # Use image_b as the mask for pasting
56
  canvas_np = np.array(canvas)
57
 
58
  h, w = displacement_map.shape