Last active
October 25, 2020 14:36
-
-
Save indreklasn/a5567ab69957128dd5e50e5ef917958c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sharp = require("sharp"); | |
sharp("example-image.jpg") | |
.resize({ width: 500, height: 450 }) | |
.toFormat("png") | |
.png({ quality: 100 }) | |
.toFile("output.png") | |
.then(() => { | |
// This is where you can either store the image to the database | |
// or | |
// Send the image to the frontend client (React, Vue, Angular, etc) | |
}) | |
.catch((err) => console.warn(err)); // send a warning to the console if there are any errors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment