webp lol
This commit is contained in:
@ -51,13 +51,15 @@ export default async bot => {
|
||||
case "stats":
|
||||
const dirs = {
|
||||
b: await fs.readdir("./public/b"),
|
||||
t: await fs.readdir("./public/t")
|
||||
t: await fs.readdir("./public/t"),
|
||||
ca: await fs.readdir("./public/ca")
|
||||
};
|
||||
const sizes = {
|
||||
b: lib.formatSize((await Promise.all(dirs.b.map(async file => (await fs.stat(`./public/b/${file}`)).size))).reduce((a, b) => b + a)),
|
||||
t: lib.formatSize((await Promise.all(dirs.t.map(async file => (await fs.stat(`./public/t/${file}`)).size))).reduce((a, b) => b + a)),
|
||||
ca: lib.formatSize((await Promise.all(dirs.ca.map(async file => (await fs.stat(`./public/ca/${file}`)).size))).reduce((a, b) => b + a)),
|
||||
};
|
||||
return e.reply(`${dirs.b.length} f0cks: ${sizes.b}, ${dirs.t.length} thumbnails: ${sizes.t}`);
|
||||
return e.reply(`${dirs.b.length} f0cks: ${sizes.b}, ${dirs.t.length} thumbnails: ${sizes.t}, ${dirs.ca.length} coverarts: ${sizes.ca}`);
|
||||
case "limit":
|
||||
return e.reply(`up to ${lib.formatSize(cfg.main.maxfilesize)} (${lib.formatSize(cfg.main.maxfilesize * 2.5)} for admins)`);
|
||||
case "thumb":
|
||||
|
@ -142,24 +142,28 @@ export default async bot => {
|
||||
try {
|
||||
await exec(`wget "${cover}" -O ./tmp/${itemid}.jpg`);
|
||||
const size = (await fs.promises.stat(`./tmp/${itemid}.jpg`)).size;
|
||||
if(size >= 0)
|
||||
if(size >= 0) {
|
||||
await exec(`convert ./tmp/${itemid}.jpg ./tmp/${itemid}.png`);
|
||||
await fs.promises.unlink(`./tmp/${itemid}.jpg`);
|
||||
await exec(`convert ./tmp/${itemid}.jpg -resize 50% ./public/ca/${itemid}.webp`);
|
||||
}
|
||||
} catch(err) {}
|
||||
}
|
||||
else
|
||||
else {
|
||||
await exec(`ffmpeg -i ./public/b/${filename} -update 1 -map 0:v -map 0:1 -c copy ./tmp/${itemid}.png`);
|
||||
await exec(`convert ./tmp/${itemid}.png ./public/ca/${itemid}.webp`);
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
await exec(`ffmpeg -i ./public/b/${filename} -update 1 -map 0:v -map 0:1 -c copy ./tmp/${itemid}.png`);
|
||||
await fs.promises.copyFile(`./tmp/${itemid}.png`, `./public/ca/${itemid}.png`);
|
||||
await exec(`convert ./tmp/${itemid}.png ./public/ca/${itemid}.webp`);
|
||||
}
|
||||
}
|
||||
|
||||
await exec(`convert "./tmp/${itemid}.png" -resize "128x128^" -gravity center -crop 128x128+0+0 +repage ./public/t/${itemid}.png`);
|
||||
await fs.promises.unlink(`./tmp/${itemid}.png`);
|
||||
|
||||
|
||||
await exec(`convert "./tmp/${itemid}.png" -resize "128x128^" -gravity center -crop 128x128+0+0 +repage ./public/t/${itemid}.webp`);
|
||||
await fs.promises.unlink(`./tmp/${itemid}.png`).catch(err => {});
|
||||
await fs.promises.unlink(`./tmp/${itemid}.jpg`).catch(err => {});
|
||||
} catch(err) {
|
||||
await fs.promises.copyFile('./mugge.png', `./public/t/${itemid}.png`);
|
||||
await exec(`convert ./mugge.png ./public/t/${itemid}.webp`);
|
||||
}
|
||||
|
||||
let speed = lib.calcSpeed(size, end);
|
||||
|
Reference in New Issue
Block a user