Skip to content

Instantly share code, notes, and snippets.

@MrPowerGamerBR
Created February 23, 2016 21:06
Show Gist options
  • Select an option

  • Save MrPowerGamerBR/9350f53f890e7604eb85 to your computer and use it in GitHub Desktop.

Select an option

Save MrPowerGamerBR/9350f53f890e7604eb85 to your computer and use it in GitHub Desktop.
from PIL import Image
import os
im = Image.open("Voto_Carinha.png")
size = (3264,1216) # size of the image to create
im2 = Image.new('RGB', size) # create the image
x = 0;
y = 0;
path = 'C:\Users\User\Documents\Python\skins'
for filename in os.listdir(path):
if (filename.endswith(".png")):
if (x > 3264):
x = 0;
y = y + 32;
if (y > 1216):
print "high"
break;
# do your stuff
im = Image.open(path + "\\" + filename)
im = im.resize((32, 32))
box = (0, 0, 32, 32)
loc = (0, 0, x, y)
region = im.crop(box)
im2.paste(region, (x, y))
x = x + 32;
print x;
print y;
print filename
im2.save("skins.png");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment