parse-base64-image
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

Parse Base64 Image

Parse base64 image from HTML rich text editor input.

Install

yarn: parse-base64-image

yarn add parse-base64-image

npm: parse-base64-image

npm install parse-base64-image

Example

import fs from 'fs'
import path from 'path'
import ParseBase64Image from "parse-base64-image"

const HTMLInput = fs.readFileSync(path.join(__dirname, 'input.html'))

ParseBase64Image(HTMLInput.toString('utf-8'), path.join(__dirname, './'), '/').then(HTMLOutput => {
  console.log(HTMLOutput)
})

Details

parse-base64-image can parse HTML input from rich text editor that contain base64 image on the img tag. The rule is only if you put image from rich text editor, you need to make sure that rich editor provide the data-filename dataset like <img src="http://example.png" data-filename="example.png"/>

Test

Using yarn: yarn test

or using npm: npm run test

API

ParseBase64Image(HTMLContent: string, localPath: string, publicPath: string): Promise<string>

  • HTMLContent: required. HTML input string
  • localPath: required. Local path where is file will be saved
  • publicPath: required. Public path that accessible from public url

Package Sidebar

Install

npm i parse-base64-image

Weekly Downloads

6

Version

1.0.7

License

MIT

Unpacked Size

6.79 kB

Total Files

6

Last publish

Collaborators

  • maulanasatyaadi