Convert any file to a PNG image and back, from the command line.
npm install -g data2imagedata2image encode photo.jpg
# → photo.jpg.d2i.pngdata2image decode photo.jpg.d2i.png
# → photo.jpg# Encode multiple files
data2image encode *.pdf *.docx
# Encode with output directory
data2image encode documents/*.pdf -o output/
# Decode all .d2i.png files
data2image decode *.d2i.png -o restored/# Encode to stdout (single file)
data2image encode secret.txt --stdout > secret.d2i.png
# Use in pipelines
data2image encode data.json --stdout | someOtherCommandEncode file(s) into PNG image(s).
Arguments:
<files...>: File path(s) or glob pattern(s) to encode
Options:
-o, --output <dir>: Output directory (default: same as input file)--stdout: Write PNG to stdout (single file only)
Examples:
data2image encode report.pdf
data2image encode *.txt -o encoded/
data2image encode archive.zip --stdout > out.pngDecode Data2Image PNG(s) back to original file(s).
Arguments:
<files...>: PNG file path(s) or glob pattern(s) to decode
Options:
-o, --output <dir>: Output directory (default: same as input file)
Examples:
data2image decode image.d2i.png
data2image decode *.d2i.png -o restored/- Encode any file type to PNG
- Perfect lossless round-trip
- Glob pattern support for bulk operations
- CRC-32 integrity verification
- Progress indicators
- Stdout support for piping
- Cross-platform (Windows, macOS, Linux)
- File data is compressed with deflate
- Wrapped in a binary frame with magic bytes, CRC-32, and filename
- Laid out as RGBA pixels in a square PNG image
- Decode reverses the process and verifies integrity
Encoded files use .d2i.png extension so they're still viewable as regular PNG images.
- @data2image/core: Core library (use this for programmatic access)
- Website: Web app with drag-and-drop
- Archive files as images for platforms that only accept images
- Embed data in image-sharing sites
- Create visual representations of file data
- Backup files as PNGs
- Data exfiltration research/testing