Skip to content

Encode image from uri or image file to base64 on Node.js

License

Notifications You must be signed in to change notification settings

Rossb0b/imageToBase64

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Nov 27, 2023
a4b3697 · Nov 27, 2023

History

39 Commits
Nov 24, 2023
Nov 26, 2023
Nov 26, 2023
Feb 24, 2021
Feb 24, 2021
Feb 24, 2021
Feb 24, 2021
Nov 26, 2023
Feb 25, 2021
Dec 13, 2021
Nov 27, 2023
Nov 27, 2023
Nov 25, 2023

Repository files navigation

imageToBase64

Encode Media from uri or file to base64 on Node.js

Installation

$ npm install @rossbob/image-to-base64

Unit Test

  • Jest
  • Coverage : 100%

Usage

toBase64(image: Media): Promise

interface Media {
  path?: string,
  uri?: string,
}
import { toBase64 } from "@rossbob/image-to-base64";

async function main() {
  const imageBase64WithFile = await toBase64({ path: "./hdm-panda-chine.jpg" });

  const imageBase64WithURI = await toBase64({ uri: "https://www.ecosia.org/images?q=panda#id=9E3AE73E84FAAFFC7DD4D3725F33ADFD2346CA77" })
}

main().catch(console.error);