Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@crazytoucan/pngjs-draw
Advanced tools
Adds basic drawing functionnalities to pngjs node module.
$ npm install --save pngjs-draw
var fs = require('fs');
var drawing = require('pngjs-draw');
var png = drawing(require('pngjs').PNG);
fs.createReadStream("blue.png")
.pipe(new png({ filterType: 4 }))
.on('parsed', function() {
// Draws a pixel with transparent green
this.drawPixel(150,200, this.colors.black())
// Draws a line with transparent red
this.drawLine(0,0,200,200, this.colors.red(50))
// Draws a rectangle with transparent black
this.fillRect(150,150,75,20, this.colors.black(100))
// Draws a filled rectangle with transparent white
this.fillRect(50,50,100,100, this.colors.white(100))
// Draws a text with custom color
this.drawText(20,20, "Hello world !", this.colors.new(255,100,10))
// Writes file
this.pack().pipe(fs.createWriteStream('blue.out.png'));
});
Draws the pixel at the given coordinates with the given color.
int
} x
The x coordinate of the pixelint
} y
The y coordinate of the pixelArray(byte)
} color
The color used to paint the pixelDraws a line beetween two points with the given color.
int
} x0
The x coordinate of the startint
} y0
The y coordinate of the startint
} x1
The x coordinate of the endint
} y1
The y coordinate of the endArray(byte)
} color
The color used to paint the lineDraws a stroked rectangle with the given color.
int
} x
The top left x coordinate of the rectangleint
} y
The top left y coordinate of the rectangleint
} width
The width of the rectangleint
} height
The height of the rectangleArray(byte)
} color
The color used to paint strokes of the rectangleDraws a filled rectangle with the given color.
int
} x
The top left x coordinate of the rectangleint
} y
The top left y coordinate of the rectangleint
} width
The width of the rectangleint
} height
The height of the rectangleArray(byte)
} color
The color used to fill the rectangleDraw a text to the image.
int
} x
The top left x coordinate of the stringint
} y
The top left y coordinate of the stringstring
} text
The string valueArray(byte)
} color
The color used used as foregroundObject
} font
The font used to render the string (optional)Object
} text
The string valuereturn {int
} The length in pixel of the rendered string
Measure the rendered text length with the given font.
string
} text
The string valueArray(byte)
} color
The color used used as foregroundObject
} font
The font used to render the string (optional)return {int
} The length in pixel of the rendered string
[<R>,<G>,<B>,<A>]
A color is a javascript array containing Red/Green/Blue/Alpha byte components.
PNG.prototype.colors.new = function(r,g,b,a)
The new method generates an array with the provided components.
Default values :
0
0
0
255
PNG.prototype.colors.red = function(a)
PNG.prototype.colors.greed = function(a)
PNG.prototype.colors.blue = function(a)
PNG.prototype.colors.black = function(a)
PNG.prototype.colors.white = function(a)
Helper methods for creating base colors are also available.
In order to use a custom font, you must first generate a font module from an image presenting all the supported characters.
For more details, take a look at these files :
build-font.js
fonts/*
custom-font/*
MIT © Aloïs Deniel
FAQs
Adds basic drawing functionnalities to pngjs.
We found that @crazytoucan/pngjs-draw 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.