imgVcard.cjs
- inline image for vCard avatar
Last active
August 15, 2024 17:22
-
-
Save andriilive/9c1ca0648f798a05c52d3aa3f5697729 to your computer and use it in GitHub Desktop.
JS Utils
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
const fs = require('fs'); | |
function encodeImageToBase64(filePath) { | |
try { | |
const image = fs.readFileSync(filePath) | |
const base64Image = new Buffer.from(image).toString('base64'); | |
const vCardImageString = `PHOTO;ENCODING=b;TYPE=JPEG:${base64Image}`; | |
console.log(vCardImageString); | |
} | |
catch (error) { | |
console.error(error); | |
} | |
} | |
encodeImageToBase64("./ava.jpeg"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment