1.0.7 • Published 3 years ago

parse-base64-image v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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
1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago