Parse base64 image from HTML rich text editor input.
yarn add parse-base64-image
npm install parse-base64-image
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)
})
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"/>
Using yarn:
yarn test
or using npm:
npm run test
HTMLContent
: required. HTML input stringlocalPath
: required. Local path where is file will be savedpublicPath
: required. Public path that accessible from public url