0

I'm have a SQL Server database with images of type varbinary. I need to convert the varbinary and return the image to a web page. Help would be appreciated.

I found this and it was very helpful, but I need it in reverse. Node.js How to convert to image from varbinary of MS Sql server datatype

Something like ...

var image  = new Buffer(rs.recordset[0].Image).toString('base64');
                    res.type('image/jpeg; charset=utf-8');
                    res.status(200).end(image);
<ng-template ngbSlide *ngFor="let image of images">
          <img class="center-block" src="data:image/JPEG;base64,{{image}}">
        </ng-template>

And my service is like this ...

 getImage(query){
    
       return this._http.get(this.API_URL + this.baseUrl + query)
         .map(res => res.json());
    
   }

1

1 Answer 1

1

This was the answer.

res.writeHead(200, {'Content-Type': 'image/jpeg'});
//var image = rs;
var image  = new Buffer(rs.recordset[0].Image);
res.end(image);

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.