I'm working on a project which requires an image database. Many of the images are rather larger than they need to be for 90% of the use cases of the application, however, there are cases where I need the original quality image.Therefore, I cannot reduce the image before uploading/saving to the filesystem (MongoDB database).
My plan was to reduce the size of the image after retrieving the original from MongoDB but before actually sending it from the Node server to the Angular client.
I cannot find an example of this using either Sharp or Jimp (which seem to be leading contenders) and I'm struggling to make either work:
- When I use Jimp, I get errors about the constructor.
- When I use Sharp it throws errors because it doesn't like the input - it seems to want the original JPEG or PNG as input, which obviously I don't have as the returned image is an object with a buffer binary field.
Could anyone point me in the right direction about how to achieve this?