title: JavaScript Convert Canvas To PGM
body: <p>I am trying to convert canvas in JavaScript to pgm.
  After i convert the file and download it to my desktop, it has the pgm extension, but when i open it with editor it is coded as png.
  i think if JavaScript didn't recognize the extension that you want to convert to, it will convert it by default to png.
  So JavaScript can convert to png, jpeg etc, but not to pgm ?</p>
  
  <p>My question is it possible to convert canvas to pgm using JavaScript, if not is there any available plugin or Js library to do so.</p>
  
  <pre><code>function image_download() {
      canvas = $('#canvas').get(0);
      var image = new Image();
      image.src = canvas.toDataURL("image/pgm");
  
  
      var download = document.createElement('a');
      download.href = image.src;
      download.download = 'map.pgm';
      download.click();
  }
  </code></pre>