mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-10-01 01:05:53 -04:00
Contain Telegram stickers in a 512x512 box
Fixes https://github.com/turt2live/matrix-dimension/issues/251
This commit is contained in:
parent
630a236d7d
commit
f894af79b6
@ -81,8 +81,12 @@ export class AdminStickerService {
|
||||
for (const tgSticker of tgPack.stickers) {
|
||||
LogService.info("AdminStickerService", "Importing sticker from " + tgSticker.url);
|
||||
const buffer = await mx.downloadFromUrl(tgSticker.url);
|
||||
console.log(typeof(buffer));
|
||||
const png = await sharp(buffer).png().toBuffer();
|
||||
const png = await sharp(buffer).resize({
|
||||
width: 512,
|
||||
height: 512,
|
||||
fit: 'contain',
|
||||
background: 'rgba(0,0,0,0)',
|
||||
}).png().toBuffer();
|
||||
const mxc = await mx.upload(png, "image/png");
|
||||
const serverName = mxc.substring("mxc://".length).split("/")[0];
|
||||
const contentId = mxc.substring("mxc://".length).split("/")[1];
|
||||
|
Loading…
Reference in New Issue
Block a user