Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
@alttiri/get-image-data
Advanced tools
A simple library to get ImageData on Node.js and browsers
A simple JS library to get ImageData
.
npm i @alttiri/get-image-data
In Node.js use getImageDataWithSharp
to get ImageData
with sharp
library.
Do not forget to install sharp
(npm i sharp
).
Since sharp
is not included as a dependency (This allows you to install the version of sharp
you need).
For browsers just use getImageDataWithCanvas
.
It uses OffscreenCanvas
to get the ImageData
for File
/Blob
input.
You can get File
from the HTML input element, and Blob
from fetch
response.
npm i @alttiri/get-image-data sharp
string
) as input:import {getImageDataWithSharp as getImageData} from "@alttiri/get-image-data";
const imagePath = "C:/Windows/IdentityCRL/WLive48x48.png";
const imageData = await getImageData(imagePath);
console.log(imageData);
ArrayBufferLike
/ArrayBufferView
:import {getImageDataWithSharp as getImageData} from "@alttiri/get-image-data";
import fs from "node:fs/promises";
const imagePath = "C:/Windows/IdentityCRL/WLive48x48.png";
const fileBuffer = await fs.readFile(imagePath);
const imageData = await getImageData(fileBuffer);
console.log(imageData);
The result:
{
width: 48,
height: 48,
data: Uint8ClampedArray(9216) [255, 255, 255, 0, ...],
colorSpace: "srgb"
}
npm i @alttiri/get-image-data
File
from HTMLInputElement
:import {getImageDataWithCanvas as getImageData} from "@alttiri/get-image-data";
const input = document.querySelector(`input[type="file"]`);
input.onchange = async function() {
const file = input.files[0];
const imageData = await getImageData(file);
console.log(imageData);
}
Blob
from fetch
response:import {getImageDataWithCanvas as getImageData} from "@alttiri/get-image-data";
const imageUrl = "https://i.imgur.com/DR94LKg.jpeg";
const resp = await fetch(imageUrl);
const blob = await resp.blob();
const imageData = await getImageData(blob);
console.log(imageData);
FAQs
A simple library to get ImageData on Node.js and browsers
We found that @alttiri/get-image-data demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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 researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.