From 9104a9b4713b1c5a194a8f9f955240318a5d4b2d Mon Sep 17 00:00:00 2001 From: Kaiserdj Date: Fri, 6 Nov 2020 15:52:35 +0100 Subject: [PATCH] fix: Add StickerGif compatibility with Webp format (#278) It works the same as gif files, and has the same color loss problem as gifs: https://github.com/orkestral/venom/issues/277#issuecomment-719068476 --- README.md | 2 +- src/api/layers/sender.layer.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bbe232cda..580251404 100644 --- a/README.md +++ b/README.md @@ -387,7 +387,7 @@ await client }); // Generates sticker from the provided animated gif image and sends it (Send image as animated sticker) -// image path imageBase64 A valid gif image is required. You can also send via http/https (http://www.website.com/img.gif) +// image path imageBase64 A valid gif and webp image is required. You can also send via http/https (http://www.website.com/img.gif) await client .sendImageAsStickerGif('000000000000@c.us', './image.gif') .then((result) => { diff --git a/src/api/layers/sender.layer.ts b/src/api/layers/sender.layer.ts index e6f848353..af6491e11 100644 --- a/src/api/layers/sender.layer.ts +++ b/src/api/layers/sender.layer.ts @@ -514,13 +514,13 @@ export class SenderLayer extends ListenerLayer { * @param to chatId '000000000000@c.us' */ public async sendImageAsStickerGif(to: string, path: string) { - let b64 = await downloadFileImgHttp(path, ['image/gif']); + let b64 = await downloadFileImgHttp(path, ['image/gif', 'image/webp']); if (!b64) { b64 = await fileToBase64(path); } if (b64) { const buff = Buffer.from( - b64.replace(/^data:image\/(gif);base64,/, ''), + b64.replace(/^data:image\/(gif|webp);base64,/, ''), 'base64' ); const mimeInfo = base64MimeType(b64);