Skip to content

Instantly share code, notes, and snippets.

@pillar
Forked from mrdoob/gist:951956
Created September 19, 2016 03:49
Show Gist options
  • Select an option

  • Save pillar/fb3746b623c483dd2a9631fcf8e46f1b to your computer and use it in GitHub Desktop.

Select an option

Save pillar/fb3746b623c483dd2a9631fcf8e46f1b 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