Abstract some hard coded numbers into variables
This commit is contained in:
parent
2b76bfdb6b
commit
9e387dc323
|
@ -1,12 +1,14 @@
|
||||||
import glob
|
import glob
|
||||||
import PIL.Image
|
import PIL.Image
|
||||||
|
fw = 500
|
||||||
|
fh = 250
|
||||||
for f in glob.glob("*-a.png"):
|
for f in glob.glob("*-a.png"):
|
||||||
old = PIL.Image.open(f)
|
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 x in range(old.width):
|
||||||
for y in range(old.height):
|
for y in range(old.height):
|
||||||
try:
|
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:
|
except:
|
||||||
pass
|
pass
|
||||||
new.save(f.replace("-a.png", "-b.png"))
|
new.save(f.replace("-a.png", "-b.png"))
|
||||||
|
|
Loading…
Reference in New Issue