
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
image-pixelizer
Advanced tools
A tool to generate pixel arts from images.
Version 1.1.0
Version 1.0.7
Version 1.0.6
This tool uses a simple two-stage algorithm to create pixel arts from images.
npm install image-pixelizer --save
// Import Pixelizer.
const Pixelizer = require('image-pixelizer');
// Create Options for Pixelizer.
let options = new Pixelizer.Options()
.setPixelSize(1)
.setColorDistRatio(0.5)
.setClusterThreshold(0.01)
.setMaxIteration(10)
.setNumberOfColors(128);
// Create compatible input Bitmap.
let inputBitmap = new Pixelizer.Bitmap(
1920, // width in pixels
1080, // height in pixels
[...] // one dimension data array for RGBA bitmap
);
// Pixelize!
let outputBitmap =
new Pixelizer(inputBitmap, options).pixelize();
There are in total 5 options for the Pixelizer.
Default values:
Bitmap is a light-weight wrapper class to represent a RGBA bitmap image. It's created with width, height (both in pixels) and a one dimensional data array containing RGBA values for all pixels. Each RGBA value should be a number between 0 to 255.
An extremely simple example which has 4 pixels:
|------------------------|-----------------------|
| black (0, 0, 0, 255) | red (255, 0, 0, 255) |
|------------------------|-----------------------|
| green (0, 255, 0, 255) | blue (0, 0, 255, 255) |
|------------------------|-----------------------|
To create this bitmap:
let bitmap = new Pixelizer.Bitmap(
2,
2,
[
0, 0, 0, 255, // black
255, 0, 0, 255, // red
0, 255, 0, 255, // green
0, 0, 255, 255 // blue
]
);
If you use jimp, you might notice this shares similarity with its bitmap. This is by design, which means you can create Pixelizer Bitmap directly from jimp, and use jimp to output image file by overriding its bitmap:
Jimp.read('lenna.png')
.then(lenna => {
// Create Pixelizer bitmap from jimp.
let inputBitmap = new Pixelizer.Bitmap(
lenna.bitmap.width,
lenna.bitmap.height,
lenna.bitmap.data
);
// Pixelizer processing code...
let outputBitmap = ...
// Override jimp bitmap and output image.
lenna.bitmap.width = outputBitmap.width;
lenna.bitmap.height = outputBitmap.height;
lenna.bitmap.data = outputBitmap.data;
lenna.write('lenna-pixel.png');
})
.catch(err => {
console.error(err);
});
As you can see, there is no deep integration with jimp for the Bitmap class, so this package can be used in more use cases (of course, with the help of more adapter code for Bitmap).
FAQs
A tool to generate pixel arts from images
We found that image-pixelizer 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.