Small utility to join alpha and diffuse images

The other day we bought a "people" texture pack from pro-viz. Great resource, I liked much their cool, contemporary, world-citizen people. Fits in almost any project in the world. The only small problem, the texture come in 2 separate image sets, one for diffuse and one for alpha. This is pretty common among alpha texture packs you can find on the net.

So I built up this little utility which scans a folder for alpha and diffuse subfolders, and joins both corresponding images into one .png image. It works on linux, probably out of the box on mac too (imagemagick must be installed), and supposedly on windows too if imagemagick's "convert" utility is in the search path.

#!/usr/bin/pythonimport sys, osargs = sys.argv[1:]if len(args) == 2:    diffusedir = args[0]    alphadir = args[1]elif len(args) == 0:    diffusedir = 'Diffuse'    alphadir = 'Alpha'else:    diffusedir = alphadir = None    print '''                                                                                      joinalpha [Diffuse Folder] [Alpha Folder] - joins alpha and diffuse images                 If no folder is specified, defaults are "Alpha" and "Diffuse"                              '''if diffusedir and alphadir:    diffusedir = os.getcwd() + os.sep + diffusedir    alphadir = os.getcwd() + os.sep + alphadir    if os.path.exists(diffusedir) and os.path.exists(alphadir):        alphanames = os.listdir(alphadir)        diffusenames = os.listdir(diffusedir)        if len(alphanames) == len(diffusenames):             print 'joining ' + str(len(alphanames)) + ' files...'             for i in range(len(alphanames)):                f1 = diffusedir + os.sep + diffusenames[i]                f2 = alphadir + os.sep + alphanames[i]                fn = str(i+1).zfill(4) + '.png'                options = '-colorspace RGB -alpha Off -compose copy_opacity -composite'                execute = 'convert "' + f1 + '" "' + f2 + '" ' + options + ' "' + fn + '"'                print 'creating ' + fn                os.system(execute)       else:            print "Alpha and Diffuse folder have a different number of files"            print alphanames, len(alphanames), diffusenames, len(diffusenames)    else:        print "Couldn't find Alpha or Diffuse folders:",alphadir,diffusedirelse:    print "No Alpha and Diffuse directories specified, or no 'Alpha' and 'Diffuse' direcories in current folder"