title: How to read Buffer data of image returned by sharp?
body: <p>I'm using the sharp npm package to resize images and it return a Buffer array of what I believe are pixels. I need to get the color of each pixel. I had attempted to loop over the array at 3 indices per loop to grab rgb values, but this doesn't seem to work as I'm getting colors that I know aren't in the image. </p>
  
  <p>For example it says the twitter logo is almost 30% black. I can't find anything in the sharp docs that says what the Buffer it's returning is made of, though it says the return will be in the same form it was prior to transformation. Is there a more general understanding of what Buffers return that someone can help me out with?</p>
  
  <p>My code so far is:</p>
  
  <pre><code>sharp(image)
              .resize(2500)
              .toBuffer()
              .then( new_image =&gt;{
                  let index = 0;
                  let rgb_values = [];
                  while(index &lt; new_image.length){
                      let point = {
                          red : new_image[index],
                          green : new_image[index + 1],
                          blue : new_image[index + 2],
                      };
  
  
                  rgb_values.push(
                      {
                          red : point.red,
                          green : point.green,
                          blue : point.blue
                      }
                  );
  
                  index = index +3;
              }
  
              return resolve(rgb_values);
          } )
          .catch(e=&gt;{
              console.log(e)
          });
  </code></pre>
  
  <p>I don't know if this is helpful but this is a small sample of what sharp returns to <code>new_image</code>.</p>