from PIL import Image class RGBAPacker(object): def process(self, output_file, inputs=None): # -- we assume "inputs" is a dictionary of image files, with the keys corresponding to the channels they want packing in. inputs = inputs or dict() r = Image.open(inputs.get('r')).convert('L') g = Image.open(inputs.get('g')).convert('L') b = Image.open(inputs.get('b')).convert('L') a = Image.open(inputs.get('a')).convert('L') output = Image.merge('RGBA', r, g, b, a) output.save(output_file)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter