title: Converting the Alpha in RGBA to CSS Opacity
body: <p>I am trying to get the transparency from RGBA and convert it to CSS opacity.</p>
  
  <p>So after getting the RGBA of an image pixel using the following:</p>
  
  <pre><code>$rgb = imagecolorat($img, $j, $i);
  $colors = imagecolorsforindex($img, $rgb);
  // Printing colors, I get
  // 255,255,255,127
  // 249,161,66,126
  //...
  </code></pre>
  
  <p>For some reason, the transparency is always an integer (i.e. 127) and not a decimal number. But I want to convert that 127 figure to something I can use in CSS:</p>
  
  <pre><code>opacity:0;filter:alpha(opacity=0)
  </code></pre>
  
  <p>However, I can't work out the link between alpha in RGBA and how I can turn it into CSS opacity.</p>
  
  <p>I will be doing this for all sorts of pixels from different types of images. PNG, JPG, GIF </p>
  
  <p>Any ideas?</p>