linoyts HF Staff commited on
Commit
489e53f
·
1 Parent(s): 1ad16d4

Use black background for sheet padding (#4)

Browse files

- Use black background for sheet padding (cc1d283e1a6583dc49cdacdf4cdc2b0275d99df2)

Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -232,7 +232,7 @@ def _gallery_paths(gallery):
232
  return paths
233
 
234
 
235
- def _fit_contain(im, cw, ch, bg=(255, 255, 255)):
236
  """Scale `im` to fit *fully* inside (cw, ch) keeping aspect ratio, then center it on a
237
  padded cell. Unlike ImageOps.fit (cover + center-crop), nothing is cropped off."""
238
  fitted = ImageOps.contain(im, (cw, ch), Image.LANCZOS)
@@ -249,7 +249,7 @@ def compose_sheet(gallery):
249
  imgs = [Image.open(p).convert("RGB") for p in paths]
250
  if len(imgs) == 1:
251
  return imgs[0]
252
- BG = (255, 255, 255)
253
  CW, CH = 1536, 896
254
  canvas = Image.new("RGB", (CW, CH), BG)
255
  cols = math.ceil(math.sqrt(len(imgs))); rows = math.ceil(len(imgs) / cols); g = 16
 
232
  return paths
233
 
234
 
235
+ def _fit_contain(im, cw, ch, bg=(0, 0, 0)):
236
  """Scale `im` to fit *fully* inside (cw, ch) keeping aspect ratio, then center it on a
237
  padded cell. Unlike ImageOps.fit (cover + center-crop), nothing is cropped off."""
238
  fitted = ImageOps.contain(im, (cw, ch), Image.LANCZOS)
 
249
  imgs = [Image.open(p).convert("RGB") for p in paths]
250
  if len(imgs) == 1:
251
  return imgs[0]
252
+ BG = (0, 0, 0)
253
  CW, CH = 1536, 896
254
  canvas = Image.new("RGB", (CW, CH), BG)
255
  cols = math.ceil(math.sqrt(len(imgs))); rows = math.ceil(len(imgs) / cols); g = 16