{"id":27621778,"url":"https://github.com/neplextech/vectorizer","last_synced_at":"2025-04-23T08:04:00.209Z","repository":{"id":212720873,"uuid":"732158235","full_name":"neplextech/vectorizer","owner":"neplextech","description":"Fast Node.js library to convert raster images to svg","archived":false,"fork":false,"pushed_at":"2025-01-06T14:18:21.000Z","size":5099,"stargazers_count":94,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-18T21:17:28.377Z","etag":null,"topics":["api","fast","image-to-svg","img2svg","napi-rs","nodejs","png-to-svg","raster-to-vector","rust","svg-creator","vector-graphics"],"latest_commit_sha":null,"homepage":"https://npm.im/@neplex/vectorizer","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neplextech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-15T19:43:45.000Z","updated_at":"2025-04-17T10:07:12.000Z","dependencies_parsed_at":"2023-12-15T21:48:25.587Z","dependency_job_id":"40aa8e59-b6dc-4674-94cc-ebf9b0f97987","html_url":"https://github.com/neplextech/vectorizer","commit_stats":{"total_commits":21,"total_committers":3,"mean_commits":7.0,"dds":"0.23809523809523814","last_synced_commit":"08c0a2472a3a8688f8ad7aa546e293bc66ef8fd0"},"previous_names":["neplextech/vectorizer"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neplextech%2Fvectorizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neplextech%2Fvectorizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neplextech%2Fvectorizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neplextech%2Fvectorizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neplextech","download_url":"https://codeload.github.com/neplextech/vectorizer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249931128,"owners_count":21347273,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","fast","image-to-svg","img2svg","napi-rs","nodejs","png-to-svg","raster-to-vector","rust","svg-creator","vector-graphics"],"created_at":"2025-04-23T08:03:57.936Z","updated_at":"2025-04-23T08:04:00.201Z","avatar_url":"https://github.com/neplextech.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# @neplex/vectorizer\n\nNode.js library to convert raster images to svg using [VTracer](https://github.com/visioncortex/vtracer), with time complexity of `O(n)`.\n\n## Benchmark\n\n```js\nclk: ~5.11 GHz\ncpu: Intel(R) Core(TM) i7-14700K\nruntime: node 22.12.0 (x64-win32)\n\nbenchmark                   avg (min … max) p75   p99    (min … top 1%)\n------------------------------------------- -------------------------------\n@neplex/vectorizer           543.89 µs/iter 542.50 µs  ▆█\n                    (517.20 µs … 778.50 µs) 719.00 µs ▃██▅▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁\nimagetracerjs                  2.54 ms/iter   2.61 ms  ▃█▃▂▄\n                        (2.38 ms … 4.09 ms)   2.93 ms ██████████▄▅▄▅▂▂▁▁▁▂▁\n\nsummary\n  @neplex/vectorizer\n   4.67x faster than imagetracerjs\n```\n\nSee [benchmark](https://github.com/neplextech/vectorizer/blob/main/benchmark/bench.ts) for more details.\n\n## CLI\n\n```bash\nnpx @neplex/vectorizer ./raster.png ./vector.svg\n```\n\nUse `--help` to see all available options.\n\n## Installation\n\n```bash\nnpm install @neplex/vectorizer\n```\n\n## Usage\n\n```js\nimport { vectorize, ColorMode, Hierarchical, PathSimplifyMode } from '@neplex/vectorizer';\nimport { readFile, writeFile } from 'node:fs/promises';\n\nconst src = await readFile('./raster.png');\n\nconst svg = await vectorize(src, {\n  colorMode: ColorMode.Color,\n  colorPrecision: 6,\n  filterSpeckle: 4,\n  spliceThreshold: 45,\n  cornerThreshold: 60,\n  hierarchical: Hierarchical.Stacked,\n  mode: PathSimplifyMode.Spline,\n  layerDifference: 5,\n  lengthThreshold: 5,\n  maxIterations: 2,\n  pathPrecision: 5,\n});\n\nconsole.log(svg); // \u003csvg\u003e...\u003c/svg\u003e\nawait writeFile('./vector.svg', svg);\n```\n\nIf you want to use a synchronous API, you can use `vectorizeSync` instead.\n\n## API\n\n### `vectorize(data: Buffer, config?: Config | Preset): Promise\u003cstring\u003e`\n\nTakes an image buffer and returns a promise that resolves to an SVG string.\n\n### `vectorizeSync(data: Buffer, config?: Config | Preset): string`\n\nTakes an image buffer and returns an SVG string synchronously.\n\n### `vectorizeRaw(data: Buffer, args: RawDataConfig, config?: Config | Preset): Promise\u003cstring\u003e`\n\nTakes a raw pixel data buffer and returns a promise that resolves to an SVG string.\n\n### `vectorizeRawSync(data: Buffer, args: RawDataConfig, config?: Config | Preset): string`\n\nTakes a raw pixel data buffer and returns an SVG string synchronously.\n\n## Demo\n\nGenerated under the following configuration:\n\n```js\n{\n    colorMode: ColorMode.Color,\n    colorPrecision: 8,\n    filterSpeckle: 4,\n    spliceThreshold: 45,\n    cornerThreshold: 60,\n    hierarchical: Hierarchical.Stacked,\n    mode: PathSimplifyMode.Spline,\n    layerDifference: 6,\n    lengthThreshold: 4,\n    maxIterations: 2\n}\n```\n\n| Raster Image (PNG Input)                                                                                                                                                                                                         | Vector Image (Generated SVG)                                                                                                                                                                                                 |\n| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| ![Raster Image](https://raw.githubusercontent.com/neplextech/vectorizer/main/example/anime-girl.png)\u003cbr/\u003e[CC-BY-SA 3.0](https://creativecommons.org/licenses/by/3.0) by [Niabot](https://commons.wikimedia.org/wiki/User:Niabot) | ![Vector Image](https://raw.githubusercontent.com/neplextech/vectorizer/main/example/result.svg)\u003cbr/\u003e[CC-BY-SA 3.0](https://creativecommons.org/licenses/by/3.0) by [Niabot](https://commons.wikimedia.org/wiki/User:Niabot) |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneplextech%2Fvectorizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneplextech%2Fvectorizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneplextech%2Fvectorizer/lists"}