Open wbprice opened 9 years ago
its a pretty standard lib to handle this. I wrote and tested some Code to upload to s3 but its also highlights compressing the images. it also shows how to upload locally to a directory.
if you add GM in there and preprocess before uploading or uploading a image_001.jpg and image_001_thumbnail.jpg that could work.
its written in an express route project but you can copy paste the logic into a happy route with no difference besides changes in the res/req object syntax. https://github.com/stanzheng/service-testing-ground/blob/master/app/routes/uploads.js
If we go about it this way, we could actually remove the imageurl
part of the model, since that refers to an existing thumbnail and just use the fullimage
as either an image
element or something of that nature which points to the image host we have.
https://www.npmjs.com/package/gm looks fairly mature. Provides a node interface to ImageMagick running on the server.