Convert an image color/hue using PHP GD library. The Catch? It has rounded corners
<p>I'm writing code this week to dynamically change the color of images. As long as the image is square or rectangle, the code below works perfectly. However, I have an image that has rounded corners (filled with a spot color and the background outside the corners is white.)</p>

<p>Can someone tell me if there's a simple way to color an image that has rounded corners using the imagecolorset function (or any other php method)?</p>

<p>I only want the non white areas of the image to be colored (In case you're wondering, I'm disallowing the color white to be applied to the image).</p>

<p>Note, perhaps a better way to do this would be to use a PNG image that has transparent background (rather than my gif image). If you think that's a better approach, please advise.</p>

<p>Here's the function that I'm working with...</p>

<pre><code>function set_theme_color_header($hex)
{
 $info = hexToRGB($hex); //calls a helper function which translates the hex to RGB
 $img = imagecreatefromgif('header-template.gif'); //again, this could be a PNG image, but we always start with this image, then create a color copy
 $color = imagecolorallocate($img, $info["red"], $info["green"], $info["blue"]);
 imagecolorset($img, 0, $info["red"], $info["green"], $info["blue"]);
 imagegif($img, 'header.gif'); //only problem is that the imagecolorset function creates a messy fill at the corners
}
</code></pre>
