Created
March 24, 2019 15:25
-
-
Save r17x/78a8ae095cfca39e1700183545fe122c to your computer and use it in GitHub Desktop.
Snippet for generate image size using sharp
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
| #!/usr/bin/env node | |
| const sharp = require('sharp') | |
| const listSize = [500, 192, 150, 64] | |
| const original = sharp('./public/logo.png') | |
| listSize.forEach(imgSize => { | |
| original | |
| .resize(imgSize, imgSize) | |
| .toFile(`./public/logo${imgSize}.png`) | |
| .then(res => { | |
| console.log(`Generated Logo with Size: ${imgSize} is OK!`) | |
| }) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment