Skip to content

Commit

Permalink
fix: Add StickerGif compatibility with Webp format (#278)
Browse files Browse the repository at this point in the history
It works the same as gif files, and has the same color loss problem as gifs:
#277 (comment)
  • Loading branch information
kaiserdj authored Nov 6, 2020
1 parent 24c57fb commit 9104a9b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions src/api/layers/sender.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9104a9b

Please sign in to comment.