
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Lite self-contained png image processing library for macOS and Linux.
node-gyp
installation docsnode-gyp
installation docs for Calalinanode-gyp
installation docsnpm install png-img
Create PngImg
object from passed buffer with image.
Arguments:
buf
- Buffer
with image file content.const fs = require('fs');
const {PngImg} = require('png-img');
const buf = fs.readFileSync('path/to/img.png');
const img = new PngImg(buf);
Get image size as an object.
console.log(img.size());
for 32x32 image will print out:
{ width: 32, height: 32 }
Get pixel color and alpha.
Returns object:
console.log(img.get(0, 0));
will print pixel and color for pixel (0, 0):
{
r: 100,
g: 150,
b: 200,
a: 255
}
Fill region with passed color. Modifies current image.
Arguments:
offsetX
- horizontal offset from the left side of the imageoffsetY
- vertical offset from the top side of the imagewidth
- region widthheight
- region heightcolor
- color as {r,g,b,a} object or as a '#XXXXXX' stringReturns: current image object
Throws if region is not inside the current image
img
.fill(0, 0, 16, 16, '#00ffFF') // fill with cyan
.fill(16, 16, 16, 16, {r: 0, g: 255, b: 255, a: 127}); // fill with half-transparent cyan
Same as fill(x, y, 1, 1, color)
Crop image. Modifies current image.
Arguments:
offsetX
- horizontal offset from the left side of the imageoffsetY
- vertical offset from the top side of the imagewidth
- new widthheight
- new heightReturns: current image object
Throws if new image is not inside the current image.
img
.crop(0, 0, 16, 16)
.crop(8, 8, 8, 8);
Sets new image size. Modifies current image.
Arguments:
width
- new widthheight
- new heightReturns: current image object
If new size is less or equal than current size, than crop
will be performed.
Note: this method doesn't strech current image, it just sets new size. If new dimension is less than previous than image will be cut. If new dimension is greater than previous than image will be extended with black area.
var size = img.size();
img
.setSize(size.width/2, size.height*2);
Inserts image into specified place.
Arguments:
img
- image to insert. Should be a PngImg objectoffsetX
- horizontal offset from the left side of the imageoffsetY
- vertical offset from the top side of the imageJoin to images (pretend that they have same witdh):
var otherImg = new PngImg(/*...*/)
img
.setSize(img.size().width, img.size().height + otherImg.size().height)
.insert(otherImg, 0, img.size().height);
Rotates image 90 degrees clockwise
Rotates image 90 degress counterclockwise
Save image to file. Asynchronous operation.
Arguments:
file
- path to file to save imageOverwrites existing file.
await img.save('path/to/file.png');
npm run build
This will build native node extension and place it to the compiled
directory
$ npm version <patch|minor|major>
$ git push && git push --tags
Use Vagrant to build and test on Linux and Windows from macOS.
Tested with Vagrant 1.7 and VirtualBox 4.3.
vagrant up --provider virtualbox
OS
env variable to run and test on specific platform:npm run build
, npm test
- current platformOS=linux npm test
- Ubuntu 14.04OS=linux-old npm test
- Ubuntu 12.04OS=win npm test
- WindowsOS=all npm test
- allFAQs
PNG Image
The npm package png-img receives a total of 1,206 weekly downloads. As such, png-img popularity was classified as popular.
We found that png-img demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers 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
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.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.