I am a beginner with node.js and I would ask you for advice. In MSSQL images are stored as varbinary enter link description here. I have written over the application in nodejs that allows access to data. I need to select images from the database, converted from varbinary to image and change their quality and re-save them as varbinary. It is the building plans enter link description here, which have a size 1.5 - 3 MB, and I need it to shrink.
Asked
Active
Viewed 1,015 times
0
-
Possible duplicate of [How to resize image in Node js](http://stackoverflow.com/q/37115815/476716). – OrangeDog Jun 09 '16 at 13:09
1 Answers
0
sql.VarBinary data type will map to a buffer in node.js.
JS Data Type To SQL Data Type Map
- String -> sql.NVarChar
- Number -> sql.Int
- Boolean -> sql.Bit
- Date -> sql.DateTime
- Buffer -> sql.VarBinary
- sql.Table -> sql.TVP
When you retrieve your binary image data from the database, you can create a buffer.
var b64str = /* data fetched from the database */;
var buf = new Buffer(b64str, 'base64');
You should be able to send the image as a buffer back to the database, if you are using the mssql package
request.input('input_parameter', sql.VarBinary, buf);

svnm
- 22,878
- 21
- 90
- 105