update: add icon padding script and assets
This commit is contained in:
+32
-26
@@ -1,29 +1,35 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const sharp = require('sharp');
|
||||
|
||||
// Fallback to Jimp if sharp is not available
|
||||
try {
|
||||
const Jimp = require('jimp');
|
||||
async function padIcon() {
|
||||
console.log('Padding icon using Sharp...');
|
||||
|
||||
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');
|
||||
// 1. Create Icon.png (1024x1024, #050510 background)
|
||||
// Scale original to 800x800 for iOS
|
||||
await sharp('Icon-original.png')
|
||||
.resize(750, 750, { fit: 'contain' })
|
||||
.extend({
|
||||
top: 137,
|
||||
bottom: 137,
|
||||
left: 137,
|
||||
right: 137,
|
||||
background: '#050510'
|
||||
})
|
||||
.toFile('Icon.png');
|
||||
console.log('Icon.png (iOS) created.');
|
||||
|
||||
// 2. Create Icon-padded.png (1080x1080, transparent background)
|
||||
// Scale original to 650x650 for Android adaptive icon safe zone
|
||||
await sharp('Icon-original.png')
|
||||
.resize(650, 650, { fit: 'contain' })
|
||||
.extend({
|
||||
top: 215,
|
||||
bottom: 215,
|
||||
left: 215,
|
||||
right: 215,
|
||||
background: { r: 0, g: 0, b: 0, alpha: 0 }
|
||||
})
|
||||
.toFile('Icon-padded.png');
|
||||
console.log('Icon-padded.png (Android) created.');
|
||||
}
|
||||
|
||||
padIcon().catch(console.error);
|
||||
|
||||
Reference in New Issue
Block a user