Skip to content

Instantly share code, notes, and snippets.

@huphtur
Created March 3, 2020 16:21
Show Gist options
  • Save huphtur/13e605fcc70a27e2bcd72dffd18b5758 to your computer and use it in GitHub Desktop.
Save huphtur/13e605fcc70a27e2bcd72dffd18b5758 to your computer and use it in GitHub Desktop.
simple node script to create thumbs out of header images
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