Skip to content

Instantly share code, notes, and snippets.

@r17x
Created March 24, 2019 15:25
Show Gist options
  • Select an option

  • Save r17x/78a8ae095cfca39e1700183545fe122c to your computer and use it in GitHub Desktop.

Select an option

Save r17x/78a8ae095cfca39e1700183545fe122c to your computer and use it in GitHub Desktop.
Snippet for generate image size using sharp
#!/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