title: Converting each pixel color of a image into json
body: <p>How would I convert each pixel color from an image into a json file.
  For example I have this 352x240 (240p) image of Mario and I wont to grab each pixel in this photo, get its rgb value and then add it to a json file from left to right, top to bottom.</p>
  
  <p><a href="https://i.stack.imgur.com/zno27.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zno27.png" alt="enter image description here"></a></p>
  
  <p>(I think you have to loop through each pixel of the image, how do you achieve this?)</p>
  
  <p>Like this: (<strong>Variable I have to make so I can use the requirement fs to save the file.</strong>)</p>
  
  <pre><code>    data: 
      [
          "0, 0, 0",
          "0, 0, 5"
      ]
  };
  </code></pre>
  
  <p>After saved it should look like this: (<strong>String</strong>)</p>
  
  <pre><code>{"data":["0, 0, 0","0, 0, 5"]}
  </code></pre>
  
  <p>My code at the moment:</p>
  
  <pre><code>var getPixels = require("get-pixels")
  var Jimp = require('jimp');
  const fs = require("fs");
  
  Jimp.read("240p.png", function (err, image) {
      var imgg = image.getPixelColor(1, 1); // For example I want to get pixel 1,1
      var imgg2 = Jimp.intToRGBA(imgg);
  
  });
  
  var obj = {
      data: 
      [
          "0, 0, 0",
          "0, 0, 5"
      ]
  };
  var filestring = JSON.stringify(obj);
  var filename = "eek"
  var file = filename
  fs.access(file, fs.F_OK, (err) =&gt; {
      if (err) {
          console.log("Creating file.")
          fs.writeFile(filename, filestring, 'utf8', function (err){
              if (err) {
                  return console.log("Something wen't wrong saving the file.")
              }
              console.log("File was successfully saved.")
          });
          return
      }
      console.log("File already exists.")
  })
  </code></pre>
  
  <p>Sources: <a href="https://www.npmjs.com/package/get-pixels" rel="nofollow noreferrer">get-pixels</a> (Gets image size)
  <a href="https://www.npmjs.com/package/jimp" rel="nofollow noreferrer">jimp</a> (Gets pixel color)</p>