Convert Hex to RGB for imagegif function
<p>The function below is designed to take an input hex (with or without the "#" prefix) and apply the color update to the portion of the image between startPixel and endPixel.</p>

<p>I can get the function to work fine on localhost tests when (1) supplying red, green, blue and (2) running the file directly as a stand alone (ie, just saving the contents of the function to a file and executing it). </p>

<p>However, I have two problems I can't seem to resolve. (1) I need to pass in a hex and get the function to work without requiring rgb hard codes and (2) I need the function to work inside my functions.php file in wordpress while saving my theme options. I'm getting a "failed to open stream" error each time I try to call the function on save.</p>

<p>`    function: </p>

<pre><code> function set_theme_color($hex)
 {
 //hexToRGB($hex); DOES NOT WORK. ALWAYS RETURNS BLACK
 $token = "images/sidebar-bg";

 $red = 0;
 $green = 0;
 $blue = 202;

 $startPixel = 601;
 $endPixel = 760;

   $img = imagecreatefromgif('images/sidebar-bg.gif');

 $color = imagecolorallocate($img, $red, $green, $blue);

 for ($i = $startPixel-1; $i &lt; $endPixel; $i++)
 {
  imagesetpixel($img, $i, 0, $color);
 }

 imagegif($img, $token.'.gif');
 }

 function hexToRGB ($hexColor)
 {
 $output = array();
 $output['red']   = hexdec($hexColor[0].$hexColor[1]);
 $output['green'] = hexdec($hexColor[2].$hexColor[3]);
 $output['blue']  = hexdec($hexColor[4].$hexColor[5]);

 return $output;
 }

 set_theme_color('#cccccc');
</code></pre>

<p>`</p>
