Starting reading a PNG file, script compress the image using RLE (run-length encoding) and then convert it in SVG format.
Here high-level steps:
- πΌ Read a png image trough
pngjslibrary - π₯ Encode png data using run-length encoding in the format 'hexColor' + 'width' (ex. #ffffff32) where:
-
hexColor (#ffffff): hexadecimal pixel color
-
width (32): number of pixels in a row
- π€ Decode RLE information and convert them in svg rects of
width=witdhandheight=1
Run-length encoding (RLE) is a form of lossless data compression in which runs of data (sequences in which the same data value occurs in many consecutive data elements) are stored as a single data value and count, rather than as the original run.
Here the list of available scripts:
Looks for png files into the folder /src/data/images and exports them in svg format under /src/data/export
npm run exportLooks for png files into the folder /src/data/images and exports the rle encoding under /src/data/encode
npm run encode