
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
png2embeddedjson
Advanced tools
Convert PNG images to embedded JSON with Base64-encoded RGB565 data.
png2embeddedjson
is a command-line tool and a Node.js module that converts PNG images into a JSON format containing Base64-encoded RGB565 data. This is useful for embedding images directly into applications or systems that utilize JSON for configuration or data representation, such as embedded systems or microcontrollers. For example, it can be used for displaying images on a GC9A01 display on an RP2040 microcontroller powered by the Kaluma runtime.
The output JSON contains:
width
: The width of the image in pixels.height
: The height of the image in pixels.bpp
: Bits per pixel used (default is 16).data
: Base64-encoded string of the RGB565 image data.Install the package globally using npm:
npm install -g png2embeddedjson
png2embeddedjson <input.png> [output.json]
<input.png>
: Path to the input PNG image.[output.json]
: (Optional) Path to save the output JSON file. If not provided, the JSON will be printed to the console.Examples:
Convert an image and save the output to a file:
png2embeddedjson example.png output.json
Convert an image and display the JSON in the console:
png2embeddedjson example.png
# Output
# {
# "width": 100,
# "height": 100,
# "bpp": 16,
# "data": "...AAECAwQFBgcICQoLDA0ODw=="
# }
Use the package programmatically in Node.js applications:
const { convert } = require('png2embeddedjson');
convert('pathToInput.png').then((json) => {
console.log(json);
// { width: 100, height: 100, bpp: 16, data: '...AAECAwQFBgcICQoLDA0ODw==' }
});
MIT © 2024 Andrew Chalkley
FAQs
Convert PNG images to embedded JSON with Base64-encoded RGB565 data
We found that png2embeddedjson 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.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.