A project that converts PNG images to SVG format by mapping each pixel into a colored rectangle.
In this algorithm, the PNG file is loaded, processed and exported as SVG for use in graphics editors.
PNG_to_SVG/
├── include/
│ ├── png2svg.h
│ └── svgToolBox.hpp
├── src/
│ ├── png2svg.cpp
│ └── main.cpp
├── images/
│ └── test.png
└── CMakeLists.txt
- CMake 3.20+
- A C++23 compatible compiler (e.g., GCC 13+, Clang 16+, MSVC 2022+)
- Zlib (for image decompression)
mkdir build
cd build
cmake ..
cmake --build .- The program loads a PNG file (Resources/image.png).
- It reads the image pixel by pixel.
- Each pixel is translated into an SVG with the corresponding color.
- Fully transparent pixels are ignored.
- The generated file output.svg preserves the color pattern of the input image.
Simply run the executable:
./png2svg png=<input.png> svg=<output.svg>
SVG : Documentation with W3C details and specifications.
PNG : Documentation with W3C details and specifications.
ZLIB : Library that implements the Deflate compression method.
This project is provided for educational purposes.
Free to use, modify, and expand with proper attribution.
Result seen in Inkscape.