Categories:
-
3d 96 articles
-
animations 16 articles
-
architecture 47 articles
-
blender 98 articles
-
bédé 19 articles
-
techdrawing 24 articles
-
freecad 189 articles
-
gaming 1 articles
-
idsampa 8 articles
-
inthepress 8 articles
-
linux 57 articles
-
music 1 articles
-
nativeifc 30 articles
-
opensource 266 articles
-
orange 4 articles
-
photo 16 articles
-
projects 35 articles
-
receitas 176 articles
-
saopaulo 18 articles
-
sketches 163 articles
-
talks 25 articles
-
techdrawing 24 articles
-
textes 7 articles
-
trilhas 3 articles
-
urbanoids 1 articles
-
video 47 articles
-
webdesign 7 articles
-
works 151 articles
Archives:
-
2007 22 articles
-
2008 32 articles
-
2009 66 articles
-
2010 74 articles
-
2011 74 articles
-
2012 47 articles
-
2013 31 articles
-
2014 38 articles
-
2015 28 articles
-
2016 36 articles
-
2017 41 articles
-
2018 46 articles
-
2019 59 articles
-
2020 18 articles
-
2021 20 articles
-
2022 7 articles
-
2023 25 articles
-
2024 14 articles
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"
Read next:
New design for my blog!:
New design for my blog!