Updated
This commit is contained in:
parent
baed4fd80e
commit
fec3abd5d8
15 changed files with 141 additions and 119 deletions
36
frontend/@dasig/scripts/node/optimizeLogo.ts
Normal file
36
frontend/@dasig/scripts/node/optimizeLogo.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { consola } from "consola";
|
||||
import process from "node:process";
|
||||
import sharp from "sharp";
|
||||
import yargs from "yargs";
|
||||
import { hideBin } from "yargs/helpers";
|
||||
|
||||
(async () => {
|
||||
const size = yargs(hideBin(process.argv)).option("size", {
|
||||
alias: "s",
|
||||
describe: "Specify the size of the logo",
|
||||
type: "number",
|
||||
demandOption: true,
|
||||
}).argv.size;
|
||||
|
||||
try {
|
||||
const webpImage = "./@dasig/images/logo.webp";
|
||||
const avifImage = "./@dasig/images/logo.avif";
|
||||
const inputSrc = "./src/images/logo.png";
|
||||
|
||||
const avifBuffer = await sharp(inputSrc)
|
||||
.avif({ quality: 60 })
|
||||
.resize(size)
|
||||
.toBuffer();
|
||||
await sharp(avifBuffer).toFile(avifImage);
|
||||
consola.success("Logo successfully optimized in Avif");
|
||||
|
||||
const webpBuffer = await sharp(inputSrc)
|
||||
.webp({ quality: 75 })
|
||||
.resize(size)
|
||||
.toBuffer();
|
||||
await sharp(webpBuffer).toFile(webpImage);
|
||||
consola.success("Logo successfully optimized in Webp");
|
||||
} catch (error) {
|
||||
consola.error("Error generating favicon:", error);
|
||||
}
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue