change opacity/alpha/transparency in png image
<p>I have a png image with transparency on it and I would like to change its opacity keeping the transparency of the pixel just add a percentage or something.
I tried using <code>putalpha</code> but it just destroys the transparency in the image.</p>

<p>What I want is something like the <code>opacity</code> property in css.</p>

<p>Thank you.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>img{opacity:.2}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;img src="http://i.imgur.com/2zGGyYB.png"/&gt;</code></pre>
</div>
</div>
</p>

<p>found a way to do it.</p>

<pre><code>image=Image.open("star_blue.png")
opacity=0.5
bands=list(self.image.split())
if len(bands)==4:
    bands[3]=bands[3].point(lambda x:x*opacity)
    new_image=Image.merge(image.mode,bands)
</code></pre>

<p>found the code <a href="http://stackoverflow.com/questions/13662184/python-pil-lighten-transparent-image-and-paste-to-another-one">here</a></p>

<p>thanks mmgp</p>

python pillow