Skip to content

ismaelfsilva/bin2c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bin2c

Embed any binary file as a C array header. A small, dependency-free Python CLI.

Usage

bin2c <input> [-o output.h] [--name NAME] [--bytes-per-line N]
  • <input>: path to the binary file to embed.
  • -o, --output: write the header to a file. If omitted, prints to stdout.
  • --name: C identifier for the array. Defaults to the sanitized input filename stem.
  • --bytes-per-line: number of bytes per line (default 12).

Example

python bin2c.py logo.png -o logo.h --name logo

Produces logo.h:

static const unsigned char logo[] = {
    0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
    ...
};
static const unsigned long logo_len = 1234;

License

MIT

About

Embed any binary file as a C array header (Python CLI).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages