Created
March 3, 2020 16:21
-
-
Save huphtur/13e605fcc70a27e2bcd72dffd18b5758 to your computer and use it in GitHub Desktop.
simple node script to create thumbs out of header images
This file contains 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 fg = require('fast-glob'); | |
const sharp = require('sharp'); | |
const headers = fg.sync(['src/posts/**/header.jpg']); | |
headers.forEach(header => { | |
thumb = header.replace("src/posts", "_site/news").replace("header", "thumb"); | |
sharp(header) | |
.jpeg({ | |
quality: 50, | |
chromaSubsampling: '4:4:4' | |
}) | |
.resize({ | |
width: 900 | |
}) | |
.toFile(thumb); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment