
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
ndarray-pixels
Advanced tools
Convert ndarray ↔ image data, on Web and Node.js.
Designed to be used with other ndarray-based packages.
In Node.js, this package uses get-pixels and save-pixels. While both packages could be used on the web, they require polyfills for Node.js builtins. Browserify handles that automatically, but more modern bundlers do not. Moreover, the polyfills increase package size significantly. To avoid these problems, web builds of ndarray-pixels
reimplement the same functionality with the more portable Canvas API.
Platform | JPEG | PNG | Other |
---|---|---|---|
Node.js | ✅ | ✅ | ❌ |
Web | ✅ | ✅ | Based on browser support |
npm install --save ndarray-pixels
import { getPixels, savePixels } from 'ndarray-pixels';
const bytesIn = await fetch('./input.png')
.then((res) => res.arrayBuffer())
.then((arrayBuffer) => new Uint8Array(arrayBuffer));
const pixels = await getPixels(bytesIn, 'image/png'); // Uint8Array -> ndarray
// ... modify ndarray ...
const bytesOut = await savePixels(pixels, 'image/png'); // ndarray -> Uint8Array
const fs = require('fs');
const { getPixels, savePixels } = require('ndarray-pixels');
const bufferIn = fs.readFileSync('./input.png');
const pixels = await getPixels(bufferIn, 'image/png'); // Uint8Array -> ndarray
// ... modify ndarray ...
const bufferOut = await savePixels(pixels, 'image/png'); // ndarray -> Uint8Array
fs.writeFileSync('./output.png', bufferOut);
▸ getPixels(data
, mimeType?
): Promise
<NdArray
>
Decodes image data to an ndarray
.
MIME type is optional when given a path or URL, and required when given a Uint8Array.
Accepts image/png
or image/jpeg
in Node.js, and additional formats on browsers with
the necessary support in Canvas 2D.
Name | Type | Description |
---|---|---|
data | string | Uint8Array | |
mimeType? | string | image/jpeg , image/png , etc. |
Promise
<NdArray
>
▸ savePixels(pixels
, mimeType
): Promise
<Uint8Array
>
Encodes an ndarray
as image data in the given format.
If the source ndarray
was constructed manually with default stride, use
ndarray.transpose(1, 0)
to reshape it and ensure an identical result from getPixels(). For an
ndarray created by getPixels(), this isn't necessary.
Accepts image/png
or image/jpeg
in Node.js, and additional formats on browsers with
the necessary support in Canvas 2D.
Name | Type | Description |
---|---|---|
pixels | NdArray <Data <number >> | ndarray of shape W x H x 4. |
mimeType | string | image/jpeg , image/png , etc. |
Promise
<Uint8Array
>
FAQs
ndarray-pixels
The npm package ndarray-pixels receives a total of 31,997 weekly downloads. As such, ndarray-pixels popularity was classified as popular.
We found that ndarray-pixels demonstrated a healthy version release cadence and project activity because the last version was released less than 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 researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.