gm icon indicating copy to clipboard operation
gm copied to clipboard

Resizing Images Which Are Stored In Database Collections

Open BobCochran opened this issue 12 years ago • 0 comments

I have a MongoDB database collection which contains high-resolution images that are stored in the collection documents. I am not using GridFS but rather storing the images in binary form using the mongodb.Binary() method.

When I query the MongoDB database for the image, it is returned to me as an Array object. That is, I make use of the toArray() method of db.collection.find(). I would like to resize the returned image to whatever new (but smaller) resolution I need for display on a web page.

Given this use case, how would you suggest I resize it?

My current approach is to try to covert the returned image object to a buffer object in base64 format, and then try to pass the buffer to 'gm' as input and have it resize the image and write it to a new output buffer. After a couple of hours of fiddling with my node.js code I still cannot get this use case to work.

Thanks for any suggestions!

Bob Cochran

BobCochran avatar Sep 02 '14 02:09 BobCochran