
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.
base64-to-tensor
Advanced tools
pure js convert a base64 image to tensor
npm i base64-to-tensor --save
Make sure to have @tensorflow/tfjs-core installed and a valid tensorflow backend set.
You also need to pick between sync package jpeg-js or async package sharp.
# pure js full sync blocking installation
npm i @tensorflow/tfjs-core jpeg-js
# if going to use async non blocking
npm i @tensorflow/tfjs-core sharp
View the convert.test.ts file for an example setup.
import { convert, convertAsync } from "base64-to-tensor";
import { setBackend } from "@tensorflow/tfjs-core";
import "@tensorflow/tfjs-backend-wasm";
await setBackend("wasm");
const tensor = convert(mybase64); // The base64 must be a valid jpeg image.
// or use native sharp for increased performance 2x [Expiremental]
const tensor = await convertAsync(mybase64);
// output example
// {
// kept: false,
// isDisposedInternal: false,
// shape: [189, 300, 3],
// dtype: "int32",
// size: 170100,
// strides: [900, 3],
// dataId: { id: 1 },
// id: 1,
// rankType: "3",
// }
The benefits of using pure js to calc the image is in a couple areas:
cairo or any of the native img dev converters.Examples of some test ran on a mac m1(64gb):
| Name | chars | size | sync | async |
|---|---|---|---|---|
| jpeg | 26791 | 26.16 KB | 100ms | 50ms |
FAQs
a pure js convert a base64 to a tensor object for node
The npm package base64-to-tensor receives a total of 14 weekly downloads. As such, base64-to-tensor popularity was classified as not popular.
We found that base64-to-tensor 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.