Last active
February 6, 2021 01:56
-
-
Save Darker935/5469c89c55beac6f439353d68d90640c to your computer and use it in GitHub Desktop.
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
var stickerExif = 0 // to prevent stickers with the same name | |
const webp = require('webp-converter'); | |
const Exif = require('/path/to/exif.js'); //https://gist.github.com/JoseHM8A/14a09d7afa34e63eb2c57492d59c2ddd | |
const exif = new Exif() | |
stickerExif++ | |
const packname = 'Pack Name' | |
const autor = 'Author' | |
exif.create(packname, autor, `stc_${author}${stickerExif}`) | |
const encryptMedia = isQuotedImage ? await quotedMsg.downloadMedia() : await msg.downloadMedia() | |
webp.buffer2webpbuffer(Buffer.from(encryptMedia.data, 'base64'), 'jpg', '-q 100') | |
.then((res) => { | |
sharp(res) | |
.resize(512, 512, { | |
fit: 'contain', | |
background: { r: 0, g: 0, b: 0, alpha: 0 }, | |
}) | |
.toFile(`./temp/stage_${author}${stickerExif}.webp`, async(err) => { | |
if (err) return console.error(err) | |
await exec(`webpmux -set exif ./temp/stc_${author}${stickerExif}.exif ./temp/stage_${author}${stickerExif}.webp -o ./temp/${author}${stickerExif}.webp`, { log: true }) | |
if (fs.existsSync(`./temp/${author}${stickerExif}.webp`)) { | |
const data = fs.readFileSync(`./temp/${author}${stickerExif}.webp`) | |
const base64exif = new MessageMedia('image/webp', data.toString('base64')) | |
await msg.reply(base64exif, null, { sendMediaAsSticker: true }) | |
fs.unlink(`./temp/${author}${stickerExif}.webp`) | |
} | |
}) | |
}) | |
.catch(async(err) => { | |
console.error(err) | |
//msg.reply(error) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment