I have an image that already stored in Firebase storage, I need to compress (not resize) the image so I can get smaller file size in Kb, but the width and height of that image is still the same. so the sequences are
- get image from firebase storage
- perform compressing image using sharp library
- and then reupload the image to the same reference in firebase storage
here is the code to perform image compressing, if using filepath as the input and the output, the code will be like this
sharp('filepath')
.resize(1000)
.png({compressionLevel: 8})
.toFile('destination', (err, info) => { ... });
I am using admin SDK and cloud function. but the problem is I don't know how to connect the image that i get from firebase storage and make it as the input for sharp (as a file path), and I don't know how to reupload back to firebase storage if the output from sharp library is as a filepath
but I don't how to get the buffer or filepath. sorry if my question is not clear, I am actually an iOS and Android developer. and I don't understand image processing in the backend. because I usually upload and download the image via mobile app.