Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resize or crop #37

Open
sasu08 opened this issue Sep 1, 2021 · 0 comments
Open

Resize or crop #37

sasu08 opened this issue Sep 1, 2021 · 0 comments

Comments

@sasu08
Copy link

sasu08 commented Sep 1, 2021

Hi! How are you? Can you tell me how to autosize the images? I'm using a whatsapp bot to make stickers, but If I don't receive an 1:1 relation image, the bot autosizes so ugly.

The current code is:

if (messageType == MessageType.image && m.message.imageMessage.url && ((m.message.imageMessage.caption == "!sticker") || (m.message.imageMessage.caption == "!Sticker"))) {
let imageBuffer = await conn.downloadMediaMessage(m);
let sticker = await imageminWebp({ preset: "icon" } })(imageBuffer);
await conn.sendMessage(m.key.remoteJid, sticker, MessageType.sticker);
console.log("Sticker enviado a : " + m.key.remoteJid);
}

I tried:

let sticker = await imageminWebp({ preset: "icon", crop: {x:512,y:512, width:512, height:512 } })(imageBuffer); await conn.sendMessage(m.key.remoteJid, sticker, MessageType.sticker);

but throws:

UnhandledPromiseRejectionWarning: Error: Error! Cannot crop picture

Can you help me? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant