Skip to main content

Img2Num C

Features​

  • Fast raster vectorization powered by the native C++ core.
  • GPU acceleration via WebGPU (Google's Dawn) where available, with a CPU fallback.
  • SVG output: Converts images directly into SVG.
  • Embeddable via CMake: Add Img2Num as a Git submodule or with find_package.

The C bindings (cimg2num.h) expose the Img2Num library as plain C functions. This is useful for:

  • Embedding Img2Num in C projects
  • Writing custom FFI wrappers
  • Minimal overhead in systems programming

Installing from Source Code​

Add Img2Num as a submodule​

Add the submodule in a folder named Img2Num
git submodule add https://github.com/Ryan-Millard/Img2Num.git Img2Num
git submodule update --init --recursive
Not Updating Submodules

Img2Num relies on Google's Dawn WebGPU implementation to speed up the library. If you do not run git submodule update --init --recursive, the library may fail to compile.

Update your CMakeLists.txt​

Add Img2Num as a subdirectory and link the library
add_subdirectory(Img2Num)
target_link_libraries(<your-project-name> PRIVATE CImg2Num)

Include an Img2Num Header​

Include any public header
#include <cimg2num.h>

Build your project​

Initialise CMake and build the project
cmake -B build .
cmake -S . --build build

You should be good to go now!

Using find_package​

Clone Img2Num​

git clone --recursive https://github.com/Ryan-Millard/Img2Num.git
cd Img2Num

Build Img2Num​

cmake -S . -B build
cmake --build build
Failed to build?
Try running this to refresh the submodules
git submodule update --init --recursive

If that doesn't work, please open an issue or a discussion on our GitHub repository.

Install the library​

cmake --install build
Optional: Go back to original directory
cd ..

Update your CMakeLists.txt​

Add Img2Num as a subdirectory and link the library
find_package(Img2Num REQUIRED)
target_link_libraries(my_app PRIVATE Img2Num::Img2Num)

Include an Img2Num Header​

Include any public header
#include <cimg2num.h>

You should be good to go now!