title: change color of multiple different rgb colors
body: <p>Hey guys i am trying to recolor the following image with php:
  <img src="https://i.stack.imgur.com/7wMso.jpg" alt="enter image description here"></p>
  
  <p>I want to give my user the possibility to change the color of the banner with a a few clicks in my php application. So i used this little experimental script i got <a href="https://stackoverflow.com/questions/4902452/how-can-i-replace-one-color-with-another-in-a-png-24-alpha-transparent-image-wit">here</a></p>
  
  <p>This is my script to change one rgb color of my image:</p>
  
  <pre><code>$imgname = "test.png";
  $im = imagecreatefrompng($imgname);
  imagealphablending($im, false);
  for ($x = imagesx($im); $x--;) {
      for ($y = imagesy($im); $y--;) {
          $rgb = imagecolorat($im, $x, $y);
          $c = imagecolorsforindex($im, $rgb);
          if ($c['red'] == 0 &amp;&amp; $c['green'] == 94 &amp;&amp; $c['blue'] == 173) { 
              $colorB = imagecolorallocatealpha($im, 255, 0, 255, $c['alpha']);
              imagesetpixel($im, $x, $y, $colorB);
          }
      }
  }
  imageAlphaBlending($im, true);
  imageSaveAlpha($im, true);
  header('Content-Type: image/png');
  imagepng($im);
  imagedestroy($im);
  </code></pre>
  
  <p>The problem is the blue color of the banner are multiple different rgb colors so how can i change all blue rgb colors at once without affecting the other colors.</p>