title: Node : how to convert from varbinary to image of SQL Server datatype
body: <p>I'm have a SQL Server database with images of type <code>varbinary</code>. I need to convert the <code>varbinary</code> and return the image to a web page. Help would be appreciated. </p>
  
  <p>I found this and it was very helpful, but I need it in reverse.
  <a href="https://stackoverflow.com/questions/41042527/node-js-how-to-convert-to-image-from-varbinary-of-ms-sql-server-datatype">Node.js How to convert to image from varbinary of MS Sql server datatype</a></p>
  
  <p>Something like ...</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var image  = new Buffer(rs.recordset[0].Image).toString('base64');
                      res.type('image/jpeg; charset=utf-8');
                      res.status(200).end(image);</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;ng-template ngbSlide *ngFor="let image of images"&gt;
            &lt;img class="center-block" src="data:image/JPEG;base64,{{image}}"&gt;
          &lt;/ng-template&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>And my service is like this ...</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code> getImage(query){
      
         return this._http.get(this.API_URL + this.baseUrl + query)
           .map(res =&gt; res.json());
      
     }</code></pre>
  </div>
  </div>
  </p>