23 lines
726 B
JavaScript
23 lines
726 B
JavaScript
const fs = require("fs");
|
|
const { execSync } = require("child_process");
|
|
|
|
// Read PNG dimensions
|
|
const buf = fs.readFileSync("screenshot-landingpage.png");
|
|
const width = buf.readUInt32BE(16);
|
|
const height = buf.readUInt32BE(20);
|
|
console.log("Original size: " + width + "x" + height);
|
|
|
|
console.log("Installing sharp for resizing...");
|
|
execSync("npm install sharp --no-save --silent", { stdio: "inherit" });
|
|
|
|
const sharp = require("sharp");
|
|
sharp("screenshot-landingpage.png")
|
|
.resize(300)
|
|
.toFile("screenshot-landingpage-thumb.png")
|
|
.then(function (info) {
|
|
console.log("Thumbnail created: " + info.width + "x" + info.height);
|
|
})
|
|
.catch(function (err) {
|
|
console.error("Error:", err);
|
|
process.exit(1);
|
|
}); |