Skip to content

Instantly share code, notes, and snippets.

@mrdoob
Created May 2, 2011 17:24
Show Gist options
  • Save mrdoob/951956 to your computer and use it in GitHub Desktop.
Save mrdoob/951956 to your computer and use it in GitHub Desktop.
Create RGB image (A replacing B channel) out of RGBA image.
from PIL import Image
import glob, os
for infile in glob.glob( "*.png" ):
file, ext = os.path.splitext( infile )
im = Image.open( infile )
im.load()
r, g, b, a = im.split()
im2 = Image.merge("RGB", (r,g,a))
im2.save( file + "_packed.png", "PNG" )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment