code: def is_transparent(image):
      
      if not isinstance(image, Image.Image):
          # Can only deal with PIL images, fall back to the assumption that that
          # it's not transparent.
          return False
      return (image.mode in ('RGBA', 'LA') or
              (image.mode == 'P' and 'transparency' in image.info))
docs: Check to see if an image is transparent.