1.0.5 • Published 2 months ago
weimgtobase64 v1.0.5
weimgtobase64
install
npm install weimgtobase64
# common JS
const weimgtobase64 = require('weimgtobase64')
# es6
import weimgtobase64 from 'weimgtobase64'
use
// parse img url
const url = 'http://img.qipeiren.com/UploadFile/UserProPic/2019/11/23/4b65b8aadcfb0ac65a91.jpg'
console.log(weimgtobase64.parse(url))
// parse img object
const img = document.getElementById('test')
console.log(weimgtobase64.parse(img))
// useCanvas img object
const img = document.getElementById('test')
console.log(weimgtobase64.useCanvas(img))
function
function | parameter | default | required | description |
---|---|---|---|---|
parse | string/object | optional | a img object or img url | |
useCanvas | object | required | a img object |
tips
As soon as you draw into a canvas any data that was loaded from another origin without CORS approval, the canvas becomes tainted.A tainted canvas is one which is no longer considered secure, and any attempts to retrieve image data back from the canvas will cause an exception to be thrown.