2023-04-07 09:08:20 +00:00
|
|
|
#!/bin/env node
|
2022-01-11 00:34:27 +00:00
|
|
|
/* eslint-env es6 */
|
2022-01-06 23:53:54 +00:00
|
|
|
|
|
|
|
const sharp = require('sharp')
|
|
|
|
const path = require('path')
|
|
|
|
|
2023-02-14 09:19:55 +00:00
|
|
|
const inputDir = './assets/images/avatars/'
|
2022-01-06 23:53:54 +00:00
|
|
|
const outputDir = './dist/server/avatars/'
|
|
|
|
const backgrounds = [
|
|
|
|
'#ffffff',
|
|
|
|
'#000000',
|
|
|
|
'#ff0000',
|
|
|
|
'#00ff00',
|
|
|
|
'#0000ff',
|
|
|
|
'#808000',
|
|
|
|
'#ffff00',
|
|
|
|
'#008000',
|
|
|
|
'#008080',
|
|
|
|
'#00ffff',
|
|
|
|
'#000080',
|
|
|
|
'#800080',
|
|
|
|
'#ff00ff'
|
|
|
|
]
|
|
|
|
const count = 10
|
|
|
|
|
|
|
|
for (let i = 1; i <= count; i++) {
|
|
|
|
const inputFile = path.join(inputDir, i + '.svg')
|
|
|
|
|
|
|
|
for (let j = 0; j < backgrounds.length; j++) {
|
|
|
|
const out = i + (count * j)
|
|
|
|
const background = backgrounds[j]
|
2022-01-07 10:29:20 +00:00
|
|
|
sharp(inputFile).flatten({background}).resize(120, 120).jpeg({quality: 95, mozjpeg: true}).toFile(path.join(outputDir, out.toString() + '.jpg'))
|
2022-01-06 23:53:54 +00:00
|
|
|
}
|
|
|
|
}
|
2023-09-25 09:20:46 +00:00
|
|
|
|
|
|
|
// Moderation bot avatar: for now taking image 2, and applying a grey background.
|
|
|
|
{
|
|
|
|
const i = 2
|
|
|
|
const inputFile = path.join(inputDir, i + '.svg')
|
|
|
|
|
|
|
|
const background = '#858da0'
|
|
|
|
const outputDir = './dist/server/bot_avatars/'
|
|
|
|
const out = 1
|
|
|
|
sharp(inputFile).flatten({background}).resize(120, 120).jpeg({quality: 95, mozjpeg: true}).toFile(path.join(outputDir, out.toString() + '.jpg'))
|
|
|
|
}
|