Quickstart
This is the fast path to a working Img2Num build from source. If you just want to get the dev environment running and produce your first build, follow the steps below. For the full breakdown of requirements, see the Setup & Dependencies page
Img2Num ships a Justfile
that wraps every common build and run task behind a single just
command. The Docker dev image already has just (and the full C++/WASM/Python/JS toolchain)
installed, so there is nothing extra to set up.
1. Clone the repository
git clone --recursive https://github.com/Ryan-Millard/Img2Num.git
cd Img2Num/
The
--recursiveflag pulls the required submodules. If you forgot it,just init(below) will pull them for you.
2. Start the dev environment
All just commands are meant to run inside the Docker dev container, which already
has just and the complete toolchain installed.
- Linux / macOS
- Windows CMD
- PowerShell
./img2num sh
.\img2num.bat sh
.\img2num.ps1 sh
You are now in the container's shell. Every command from here on is a just recipe.
Run just (or just help) at any time to print the full list of recipes.
3. Initialise and build everything
just init
just init pulls the git submodules and then runs just build all, which compiles the
C++ core + C bindings, the WASM/JS bindings, the Python package, the
React example app, and the documentation site.
This is the only command most contributors need to get a complete, working checkout.
4. Build Targets
Already initialised and only want to rebuild one piece? Pass a target to just build
from inside the Docker terminal:
- C++ / C
- JS / WASM
- npm Package
- Python
- Everything
just build cpp
just build js
just build js only produces the raw WASM/JS bindings. To build the publishable
img2num npm package — which targets both the browser and Node.js — run
just build packages-js. It compiles the WASM bindings first (so it works from a
clean checkout) and then bundles the browser and Node builds into
packages/js/dist/.
just build packages-js
just build py
just build all
5. Clean Build Targets
To remove generated build folders:
- C++ / C
- JS / WASM
- npm Package
- Python
just clean cpp
just clean js
just clean packages-js
just clean packages-py
6. Run something
Documentation site
just docs start # serve the Docusaurus site on http://localhost:3000
just docs build # produce a static production build
React example app
just react-js start # dev server on http://localhost:5173
just react-js build # production build
react-js depends on the WASM build and will compile it automatically if needed.
Console example apps
Convert an image straight from the command line in your language of choice:
just console-cpp path/to/image.png # C++ example app
just console-c path/to/image.png # C example app
just console-py path/to/image.png # Python example app
just console-js path/to/image.png # Node.js example app
The console C/C++ apps require a prior just build cpp (or just init). The Node.js app
(console-js) requires a prior just build packages-js (or just init) and decodes the
input image with sharp. The Python app installs its
own runtime dependencies on first run.
6. Format your changes
Before opening a pull request, format everything:
just format
Command reference
| Command | What it does |
|---|---|
just / just help | List all available commands |
just init | Pull submodules, then build all targets |
just build cpp|js|packages-js|py|all | Build the C++/C, JS/WASM, npm packages, Python, or all targets |
just clean cpp|js|packages-js|packages-py | Delete the corresponding build folder |
just format | Format all files |
just docs build|start | Build or serve the documentation site |
just react-js build|start | Build or serve the React example app |
just console-cpp|console-c|console-py|console-js <image> | Run a console example app on an image |