-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add StickerGif compatibility with Webp format (#278)
It works the same as gif files, and has the same color loss problem as gifs: #277 (comment)
- Loading branch information
Showing
2 changed files
with
3 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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('[email protected]', './image.gif') | ||
.then((result) => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -514,13 +514,13 @@ export class SenderLayer extends ListenerLayer { | |
* @param to chatId '[email protected]' | ||
*/ | ||
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); | ||
|