
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@xg4/text2image
Advanced tools
convert text to image by canvas
# npm
$ npm install @xg4/text2image --save
# yarn
$ yarn add @xg4/text2image
import Text2Image from '@xg4/text2image'
const ti = new Text2Image()
// or
// initialization default options
const ti = new Text2Image({
fontSize: 13,
color: '#000000',
fontFamily: 'arial',
fontWeight: 'bold',
type: 'image/png',
quality: 0.92,
})
// get mask image
Text2Image.createMask(imgUrl).then((image) => {
// set background image
ti.setMask(image)
})
// create object url
const url = ti.createURL('hello world')
// or
const url = ti.createURL({
text: 'hello world',
// some options
})
const img = new Image()
// img loaded, remenber to destroy object url
img.onload = function () {
ti.destroyURL(this.src)
}
img.src = url
document.body.appendChild(img)
// get mask image
Text2Image.createMask(imgUrl).then((image) => {
// set background image
ti.setMask(image)
})
// create data url
const url = ti.toDataURL('hello world')
// or
const url = ti.toDataURL({
text: 'hello world',
// some options
})
const img = new Image()
img.src = url
document.body.appendChild(img)
options
name | type | default | description |
---|---|---|---|
text | string | null | image content |
fontSize | number|string | 30 | font size(like css) |
fontWeight | number|string | normal | font weight(like css) |
fontFamily | string | arial | font family(like css) |
color | string | #000000 | font color(like css) |
type | string | image/png | image type |
quality | number | 0.92 | image quality |
alpha | number | 0.3 | mask alpha(水印图片的透明度) |
// use current options convert default options
ti.setDefaultOptions({
// some options
})
// reset default options
ti.resetDefaultOptions()
Welcome
Fork it
Submit pull request
HTMLCanvasElement.prototype.toBlob
: see MDN for details about unsupported older browsers and a simple polyfill.
;(function () {
if (!HTMLCanvasElement.prototype.toBlob) {
Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', {
value: function (callback, type, quality) {
var binStr = atob(this.toDataURL(type, quality).split(',')[1]),
len = binStr.length,
arr = new Uint8Array(len)
for (var i = 0; i < len; i++) {
arr[i] = binStr.charCodeAt(i)
}
callback(new Blob([arr], { type: type || 'image/png' }))
},
})
}
})()
Modern browsers and IE10.
![]() IE / Edge | ![]() Firefox | ![]() Chrome | ![]() Safari | ![]() Opera |
---|---|---|---|---|
IE10, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions |
MIT
FAQs
convert text to image by canvas
The npm package @xg4/text2image receives a total of 334 weekly downloads. As such, @xg4/text2image popularity was classified as not popular.
We found that @xg4/text2image demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.