Compress images before upload
Drop compresso.js into your file input handler: compress(file) returns an optimized File ready to upload. Images never leave the browser until your code sends them.
Comment ça marche
- npm install compresso.js
- Call compress(file, { quality: 0.8, maxWidth: 1920, format: "auto" }) on change.
- Upload result.file instead of the original.
Questions courantes
- Works with multipart forms?
- Yes. result.file is a standard File object for FormData.
- Need a backend?
- No. Compression is 100% client-side.
Pour les développeurs
Intégrez la compression dans votre flux d’envoi :
npm install compresso.jsnpm · Docs