-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcreate_mipmap_images.js
More file actions
31 lines (29 loc) · 1013 Bytes
/
create_mipmap_images.js
File metadata and controls
31 lines (29 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const { Jimp } = require('jimp');
const fs = require('fs');
const sizes = {
xxxhdpi: 192,
xxhdpi: 144,
xhdpi: 96,
hdpi: 72,
mdpi: 48,
ldpi: 36,
};
async function main(imageUrl) {
const image = await Jimp.read(imageUrl);
image.resize({ w: 512, h: 512 }).write('app/src/main/ic_launcher-playstore.png');
for (const [sizeName, sizePixels] of Object.entries(sizes)) {
const mipmapFolder = `app/src/main/res/mipmap-${sizeName}`;
if (!fs.existsSync(mipmapFolder)) {
fs.mkdirSync(mipmapFolder, { recursive: true });
}
const launcherPath = `app/src/main/res/mipmap-${sizeName}/ic_launcher.png`;
const roundPath = `app/src/main/res/mipmap-${sizeName}/ic_launcher_round.png`;
image.resize({ w: sizePixels, h: sizePixels }).write(launcherPath);
image.circle().write(roundPath);
}
}
if (require.main === module) {
const arg = process.argv[2];
if (!arg) throw new Error('missing argument');
main(arg);
}