title: Adding watermark to Image in Python using PIL
body: <p>I am Trying to Add an Watermark to an Image using an PIL(pillow) by this Algorithm</p>
  
  <pre><code>def watermark_image_with_text(filename):
      text = 'Watermark'
      color = 'blue'
      fontfamily = 'arial.ttf'
      image = Image.open(filename).convert('RGBA')
      imageWatermark = Image.new('RGBA', image.size, (255, 255, 255, 0))
      draw = ImageDraw.Draw(imageWatermark)
      width, height = image.size
      font = ImageFont.truetype(fontfamily, int(height / 20))
      textWidth, textHeight = draw.textsize(text, font)
      x = width / 5
      y = height / 6
      draw.text((x, y), text, color, font)
      my_img = Image.alpha_composite(image, imageWatermark)
      my_img.save('water_' + filename.name)
      return 'water_' + filename.name
  </code></pre>
  
  <p>It works Fine for PNG files but it does not apply watermark to Images of another file format such as JPG, JPEG, TIF, etc...
  can anybody suggest a Generic method for applying watermark to images of all file formats</p>
  
  <ul>
  <li>The error is <code>cannot write mode RGBA as JPEG</code></li>
  </ul>