You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
1.2 KiB

(async() => {
const siteDomain = "blog.cybershell.xyz";
const sharp = require('sharp');
const fs = require('fs');
const path = require('path');
// const iconDir = path.join(__dirname, siteDomain);
const siteImagesDir = path.join(__dirname, 'client', 'img');
const siteIconDir = path.join(siteImagesDir, 'icon', siteDomain)
const sourceIconFile = 'thumbnail.png';
const sourceIconFilePath = path.join(__dirname, sourceIconFile);
const sizes = [16, 32, 36, 48, 57, 60, 70, 72, 76, 96, 114, 120, 144, 150, 152, 180, 192, 256, 310, 384, 512];
await fs.promises.mkdir(siteIconDir, { force: true, recursive: true });
for (var size of sizes) {
await sharp(sourceIconFilePath).resize({
fit: sharp.fit.contain,
width: size,
height: size
}).png()
.toFile(path.join(siteIconDir, `icon-${size}x${size}.png`));
}
// await fs.promises.cp(sourceIconFilePath, path.join(siteIconDir, `${siteDomain}.png`));
await fs.promises.cp(sourceIconFilePath, path.join(siteImagesDir, 'social-cards', `${siteDomain}.png`));
// await fs.promises.cp(iconDir, path.join(siteImagesDir, 'icon' ), { recursive: true });
})()