def uses_transparency(filename):
    img = Image.open(filename)
trans = img.info.get('transparency', None)
if trans is not None:
    trans *= 3
palette = img.getpalette()
imgs = []
for bg in [0, 255]:
    palette[trans:trans + 3] = [bg] * 3
img.putpalette(palette)
imgs.append(img.convert('L'))
return bool(ImageChops.difference(*imgs).getbbox())
Determining if a GIF is transparent in Python