"""
Used to create d3d11x.SkyBox compatible textures from Hazel Whorley's images.
Put into a directory containing individual images and run the script.
Requires PIL.
"""
import os
import Image
#1.0 == no scaling
SCALE = 1.0
OUTPUT = "result.bmp"
names = ["_north.bmp", "_east.bmp", "_south.bmp", "_west.bmp", "_up.bmp", "_down.bmp"]
fullimage = None
imageindex = 0
imagejump = 0
def addImage(name, f):
global fullimage, imageindex, imagejump
im = Image.open(f)
im = im.resize((int(im.size[0] * SCALE), int(im.size[1] * SCALE)), Image.ANTIALIAS)
if im.size[0] % 2 != 0 or im.size[1] % 2 != 0:
print("Note: image is not a power of two.")
if fullimage is None:
#First image, create the final image.
w = im.size[0] * 6
h = im.size[1]
print("Result texture: (%ix%i)" % (w, h))
fullimage = Image.new("RGB", (w, h))
imagejump = im.size[0]
fullimage.paste(im, (imageindex * imagejump, 0))
imageindex += 1
print("Added '%s'" % f)
files = set(os.listdir("."))
found = 0
for name in names:
for f in files:
if f.endswith(name):
addImage(name, f)
found += 1
break
if found != 6:
print("Some image files are missing, there should be 6!")
fullimage.save(OUTPUT)
print("Done '%s'. Press Enter to exit." % OUTPUT)
input()