Skip to content

Commit

Permalink
Crop rather than stretch images
Browse files Browse the repository at this point in the history
  • Loading branch information
skjiisa committed Jan 6, 2021
1 parent 79dc6ec commit fe1952d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions MyQR/myqr.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ def combine(ver, qr_name, bg_name, colorized, contrast, brightness, save_dir, sa
bg0 = ImageEnhance.Brightness(bg0).enhance(brightness)

if bg0.size[0] < bg0.size[1]:
bg0 = bg0.resize((qr.size[0]-24, (qr.size[0]-24)*int(bg0.size[1]/bg0.size[0])))
bg0 = bg0.resize((qr.size[0]-24, (qr.size[0]-24)*int(bg0.size[1]/bg0.size[0])),
box=(0, (bg0.size[1] - bg0.size[0]) // 2, bg0.size[0], (bg0.size[1] + bg0.size[0]) // 2))
else:
bg0 = bg0.resize(((qr.size[1]-24)*int(bg0.size[0]/bg0.size[1]), qr.size[1]-24))
bg0 = bg0.resize(((qr.size[1]-24)*int(bg0.size[0]/bg0.size[1]), qr.size[1]-24),
box=((bg0.size[0] - bg0.size[1]) // 2, 0, (bg0.size[0] + bg0.size[1]) // 2, bg0.size[1]))

bg = bg0 if colorized else bg0.convert('1')

Expand Down

0 comments on commit fe1952d

Please sign in to comment.