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.
get-pixels
Advanced tools
The get-pixels npm package is used to read and decode image files into pixel data. It supports various image formats such as PNG, JPEG, GIF, and BMP. This package is useful for applications that need to process or analyze image data at the pixel level.
Load Image from File
This feature allows you to load an image from a file and get its pixel data. The pixel data is returned as a multi-dimensional array.
const getPixels = require('get-pixels');
getPixels('path/to/image.png', function(err, pixels) {
if (err) {
console.log('Failed to load image:', err);
return;
}
console.log('Pixels:', pixels);
});
Load Image from URL
This feature allows you to load an image from a URL and get its pixel data. This is useful for processing images hosted on the web.
const getPixels = require('get-pixels');
getPixels('http://example.com/image.jpg', function(err, pixels) {
if (err) {
console.log('Failed to load image:', err);
return;
}
console.log('Pixels:', pixels);
});
Load Image from Buffer
This feature allows you to load an image from a buffer and get its pixel data. This is useful for processing images that are already loaded into memory.
const getPixels = require('get-pixels');
const fs = require('fs');
const buffer = fs.readFileSync('path/to/image.png');
getPixels(buffer, 'image/png', function(err, pixels) {
if (err) {
console.log('Failed to load image:', err);
return;
}
console.log('Pixels:', pixels);
});
Jimp is a powerful image processing library for Node.js that supports reading and writing various image formats, manipulating images, and accessing pixel data. Compared to get-pixels, Jimp offers a broader range of image manipulation features such as resizing, cropping, and applying filters.
Sharp is a high-performance image processing library for Node.js that supports reading and writing various image formats, resizing, cropping, and converting images. Sharp is known for its speed and efficiency, making it a good choice for high-performance applications. Unlike get-pixels, Sharp focuses more on image transformation and optimization.
Pngjs is a pure JavaScript library for reading and writing PNG files. It provides access to pixel data and supports various PNG features such as transparency and color types. While pngjs is limited to PNG files, it offers more control over PNG-specific features compared to get-pixels.
Given a URL/path, grab all the pixels in an image and return the result as an ndarray. Works both in browserify and in node.js.
Note On the node side, currently only supports PNG and PPM. Patches welcome!!!
var getPixels = require("get-pixels")
getPixels("lena.png", function(err, pixels) {
if(err) {
console.log("Bad image path")
return
}
console.log("got pixels", pixels.shape)
})
npm install get-pixels
require("get-pixels")(url, cb(err, pixels))
Reads all the pixels from url into an ndarray.
url
is the path to the filecb(err, pixels)
is a callback which gets triggered once the image is loaded.Returns An ndarray of pixels in raster order having shape equal to [rows, columns, channels]
.
(c) 2013 Mikola Lysenko. MIT License
FAQs
Reads the pixels of an image as an ndarray
The npm package get-pixels receives a total of 183,950 weekly downloads. As such, get-pixels popularity was classified as popular.
We found that get-pixels 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.
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.