mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 04:02:54 -06:00
fix: preserve animation in GIF and WebP stickers
This commit is contained in:
parent
f8b1c6e0fa
commit
6e7dd51679
@ -2703,8 +2703,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
imageBuffer = Buffer.from(response.data, 'binary');
|
imageBuffer = Buffer.from(response.data, 'binary');
|
||||||
}
|
}
|
||||||
|
|
||||||
const isAnimated = image.includes('.gif') ||
|
const isAnimated = this.isAnimated(image, imageBuffer);
|
||||||
(image.includes('.webp') && this.isAnimatedWebp(imageBuffer));
|
|
||||||
|
|
||||||
if (isAnimated) {
|
if (isAnimated) {
|
||||||
return await sharp(imageBuffer, { animated: true })
|
return await sharp(imageBuffer, { animated: true })
|
||||||
@ -2722,14 +2721,14 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
private isAnimatedWebp(buffer: Buffer): boolean {
|
private isAnimatedWebp(buffer: Buffer): boolean {
|
||||||
if (buffer.length < 12) return false;
|
if (buffer.length < 12) return false;
|
||||||
|
|
||||||
for (let i = 0; i < buffer.length - 4; i++) {
|
return buffer.indexOf(Buffer.from('ANIM')) !== -1;
|
||||||
if (buffer[i] === 0x41 && // 'A'
|
}
|
||||||
buffer[i + 1] === 0x4E && // 'N'
|
|
||||||
buffer[i + 2] === 0x49 && // 'I'
|
private isAnimated(image: string, buffer: Buffer): boolean {
|
||||||
buffer[i + 3] === 0x4D) { // 'M'
|
if (image.includes('.gif')) return true;
|
||||||
return true;
|
|
||||||
}
|
if (image.includes('.webp')) return this.isAnimatedWebp(buffer);
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user