chore: add jimp dependency, icon padding script, and update configuration
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// Fallback to Jimp if sharp is not available
|
||||
try {
|
||||
const Jimp = require('jimp');
|
||||
|
||||
async function padIconJimp() {
|
||||
console.log('Padding icon using Jimp...');
|
||||
const img = await Jimp.read('Icon.png');
|
||||
// Scale down image to fit within 720x720 while maintaining aspect ratio
|
||||
img.scaleToFit(720, 720);
|
||||
|
||||
// Create a transparent 1080x1080 background
|
||||
const bg = new Jimp(1080, 1080, 0x00000000);
|
||||
|
||||
// Center the scaled image on the background
|
||||
const x = (1080 - img.bitmap.width) / 2;
|
||||
const y = (1080 - img.bitmap.height) / 2;
|
||||
|
||||
bg.composite(img, x, y);
|
||||
await bg.writeAsync('Icon-padded.png');
|
||||
console.log('Icon successfully padded to Icon-padded.png');
|
||||
}
|
||||
|
||||
padIconJimp().catch(console.error);
|
||||
} catch (e) {
|
||||
console.log('Jimp not found. Please install it first using: npm install jimp --no-save');
|
||||
}
|
||||
Reference in New Issue
Block a user