I have be attempting to resize (downsample) a RGB image using the python image library resize function. Everything works fine but I would like to exclude black values 0,0,0 from the calculations. I have tried creating a alpha mask based on black values then performing the resize but that only create partially transparent tiles in the regions that had black values
im = Image.open('src.tif') multi = im.split mask = im.point(lambda i: i == 0 and 255) # get 0 values mask = mask.convert('L') mask = ImageChops.invert(mask) # make the 0 values 255 for transparency out_im = Image.merge('RGBA', (multi[0], multi[1], multi[2], mask)) out_im = out_im.resize((100, 100), Image.ANTIALIAS) out_im = out_im.convert('RGB') out_im.save('dst.tif') Any help would be great -- Travis K. Toronto, Canada ------------------------------------------------------------ "She knows there's no success like failure And that failure's no success at all." -Bob Dylan- ------------------------------------------------------------ -- http://mail.python.org/mailman/listinfo/python-list