Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- images = [Image.open(filename).resize((300,300)) for filename in existing_images_df['impath']]
- image_width, image_height = images[0].size
- one_square_size = int(np.ceil(np.sqrt(len(images))))
- master_width = (image_width * one_square_size)
- master_height = image_height * one_square_size
- master = Image.new(
- mode='RGBA',
- size=(master_width, master_height),
- color=(0,0,0,0)) # fully transparent
- for count, image in enumerate(images):
- div, mod = divmod(count,one_square_size)
- h_loc = image_width*div
- w_loc = image_width*mod
- master.paste(image,(w_loc,h_loc))
- master.convert("RGB").save('sprite.jpg', transparency=0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement