How to Decrease Image File Size. When It Download From Google Image URL or Domain URL Using Nodejs?

904 Views Asked by At

I tried to Decrease Image File Size When It's Download From Google Image URL. I tried imagemin npm package but it's only available in javascript. I need to available on the typescript.

My Image Download Code is:

const download = (url, path, callback) => {
      request.head(url, (err, res, body) => {
             request(url)
            .pipe(fs.createWriteStream(path))
            .on('close', callback)
            })
     }

download(myUrl, myPath, () => {
          // console.log('Image download Done!')
})

Does anyone Suggest to me any Good npm package or any example for reducing the Image File Size?

1

There are 1 best solutions below

0
OBrien Evance On

You can try using the npm library called sharp

Heres the link