MCPcopy Create free account
hub / github.com/Maccoder3/MAC-MD / addExif

Function addExif

lib/sticker.js:175–195  ·  view source on GitHub ↗

* Add WhatsApp JSON Exif Metadata * Taken from https://github.com/pedroslopez/whatsapp-web.js/pull/527/files * @param {Buffer} webpSticker * @param {String} packname * @param {String} author * @param {String} categories * @param {Object} extra * @returns

(webpSticker, packname, author, categories = [''], extra = {})

Source from the content-addressed store, hash-verified

173 * @returns
174 */
175async function addExif(webpSticker, packname, author, categories = [''], extra = {}) {
176 const img = new webp.Image()
177 const stickerPackId = crypto.randomBytes(32).toString('hex')
178 const json = {
179 'sticker-pack-id': stickerPackId,
180 'sticker-pack-name': packname,
181 'sticker-pack-publisher': author,
182 emojis: categories,
183 ...extra,
184 }
185 let exifAttr = Buffer.from([
186 0x49, 0x49, 0x2a, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00,
187 0x00, 0x00, 0x16, 0x00, 0x00, 0x00,
188 ])
189 let jsonBuffer = Buffer.from(JSON.stringify(json), 'utf8')
190 let exif = Buffer.concat([exifAttr, jsonBuffer])
191 exif.writeUIntLE(jsonBuffer.length, 14, 4)
192 await img.load(webpSticker)
193 img.exif = exif
194 return await img.save(null)
195}
196
197/**
198 * Image/Video to Sticker

Callers 1

stickerFunction · 0.85

Calls 2

loadMethod · 0.80
saveMethod · 0.80

Tested by

no test coverage detected