DEV Community

Cover image for Image Compression with Node.js

Image Compression with Node.js

Francisco Mendes on May 15, 2021

Currently, I feel that the market is increasingly oriented towards the use of third-party services to make part of our pipeline. One of the most co...
Collapse
 
a14313 profile image
Carlo Autor

Thank you for this. This is what I have been looking for

Collapse
 
dilkashshaikhmahajan profile image
Dilkash Shaikh Shahagir Mahajan

After compress the image, I want to store the image in cloudinary then what will I do?

Collapse
 
franciscomendes10866 profile image
Francisco Mendes

I just happened to write an article about it, hope it helps! bit.ly/3w2UwHJ

Collapse
 
joshua_lavaud_1f2dbc81a3a profile image
Joshua Lavaud

Hello, I want delete the origin image, but i can't, why ?
Image description

Image description

Collapse
 
hnazmul profile image
H.Nazmul Hassan

wow so understandable docs. thanks you soo much

Collapse
 
franciscomendes10866 profile image
Francisco Mendes

Thank you for the feedback ☺

Collapse
 
yishai_zehavi profile image
Yishai Zehavi

That's a great article, thanks! My favorite image format would be AVIF, but it's still not supported as widely as WebP.

Collapse
 
solodovnykov profile image
Anton Solodovnykov

I have some problem, pls help to resolve this error
Image description

Collapse
 
kcouliba profile image
Coulibaly Daba Kevin

This is caused by the ":" character on windows OS.
Eventually you should replace
const timestamp = new Date().toISOString();
with
const timestamp = Date.now();

Collapse
 
sushmargowda27 profile image
Sushma R

Hi I used to this code and Compressed the image and storing in the MySQL database. but How to do decompress the image to retrieve the image from database.

Collapse
 
tarun18s profile image
tarun18s

i want to compress video how can i do that using sharp or any other way ??

Collapse
 
distil profile image
Charavner Louis

It's maybe too late for answer but you can use npmjs.com/package/fluent-ffmpeg for video compression

Collapse
 
jaypatel202002 profile image
JayPatel202002

after compression of image is done i want to upload it to my mongo DB database how can i achieve that?