Abstract some hard coded numbers into variables

This commit is contained in:
Niles Rogoff 2016-09-20 00:30:27 -04:00
parent 2b76bfdb6b
commit 9e387dc323
1 changed files with 4 additions and 2 deletions

View File

@ -1,12 +1,14 @@
import glob
import PIL.Image
fw = 500
fh = 250
for f in glob.glob("*-a.png"):
old = PIL.Image.open(f)
new = PIL.Image.new("RGB", (500, 250), (0, 0, 0))
new = PIL.Image.new("RGB", (fw, fh), (0, 0, 0))
for x in range(old.width):
for y in range(old.height):
try:
new.putpixel((int(500/2) + x - int(old.width / 2), int(250/2) + y - int(old.height / 2)), old.getpixel((x, y)))
new.putpixel((int(fw/2) + x - int(old.width / 2), int(fh/2) + y - int(old.height / 2)), old.getpixel((x, y)))
except:
pass
new.save(f.replace("-a.png", "-b.png"))