Set specific background color of image to transparent using JS
<p>I'm using the following code to modify the transparency on an image. What I would like to do however is only modify the background color of the image and set its alpha channel to 0 instead of the entire image.</p>

<p>Following code sets the alpha transparency to 0 for the entire image:</p>

<pre><code>var ctx = this.data.getContext("2d");
var imgData = ctx.getImageData(0, 0, this.data.width, this.data.height);
ctx.putImageData(this.adjustImage(imgData), 0, 0);

adjustImage: function(iArray) {
    var imageData = iArray.data;
    for (var i = 0; i &lt; imageData.length; i+= 4) {
        imageData[i+3] = 0;
    }

    return iArray;            
}
</code></pre>

<p>I'm after some help modifying only one color <code>rgb(255,0,255)</code> in the image to transparent.</p>
