mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-09-04 08:02:22 +00: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) {
|
for (const tgSticker of tgPack.stickers) {
|
||||||
LogService.info("AdminStickerService", "Importing sticker from " + tgSticker.url);
|
LogService.info("AdminStickerService", "Importing sticker from " + tgSticker.url);
|
||||||
const buffer = await mx.downloadFromUrl(tgSticker.url);
|
const buffer = await mx.downloadFromUrl(tgSticker.url);
|
||||||
console.log(typeof(buffer));
|
const png = await sharp(buffer).resize({
|
||||||
const png = await sharp(buffer).png().toBuffer();
|
width: 512,
|
||||||
|
height: 512,
|
||||||
|
fit: 'contain',
|
||||||
|
background: 'rgba(0,0,0,0)',
|
||||||
|
}).png().toBuffer();
|
||||||
const mxc = await mx.upload(png, "image/png");
|
const mxc = await mx.upload(png, "image/png");
|
||||||
const serverName = mxc.substring("mxc://".length).split("/")[0];
|
const serverName = mxc.substring("mxc://".length).split("/")[0];
|
||||||
const contentId = mxc.substring("mxc://".length).split("/")[1];
|
const contentId = mxc.substring("mxc://".length).split("/")[1];
|
||||||
|
Loading…
Reference in New Issue
Block a user