code: def reduce_opacity(im, opacity):
      
      assert opacity >= 0 and opacity <= 1
      if im.mode != 'RGBA':
          im = im.convert('RGBA')
      else:
          im = im.copy()
      alpha = im.split()[3]
      alpha = ImageEnhance.Brightness(alpha).enhance(opacity)
      im.putalpha(alpha)
      return im
docs: Returns an image with reduced opacity.