def put_original_alpha(original_image, new_image):
 try:
  alpha_idx = original_image.mode.index('A')
  alpha_channel = original_image.split()[alpha_idx]
  new_image.putalpha(alpha_channel)
 except ValueError:
  pass
 return new_image

def put_original_alpha ( original_image , new_image ) : try : alpha_idx = original_image . mode . index ( 'A' ) alpha_channel = original_image . split ( ) [ alpha_idx ] new_image . putalpha ( alpha_channel ) except ValueError : pass return new_image
put alpha channel of original image in the new image .