{"_id":"@image-tracer-ts/core","_rev":"1-af5a6892ce2c896bbe7c56648a12f97f","name":"@image-tracer-ts/core","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@image-tracer-ts/core","version":"1.0.0","description":"Convert image bitmaps into SVG by tracing outlines. Typescript version of imagetracerjs. Use imagetracerts-nodejs or imagetracerts-browser for platform-specific file input and output.","scripts":{"clean":"rimraf ./dist/*","prepack":"npm run build","rollup":"rollup --config","build":"run-s clean rollup"},"prepare":"npm run build","author":{"name":"Moritz Ringler"},"license":"MIT","devDependencies":{"@rollup/plugin-replace":"^5.0.2"},"main":"dist/index.cjs","module":"dist/index.mjs","types":"dist/index.d.ts","keywords":["image","tracer","tracing","vector","raster","vectorize","vectorizing","convert","conversion","converting","tracing","bitmap","svg"],"bugs":{"url":"https://github.com/mringler/image-tracer-ts/issues"},"homepage":"https://github.com/mringler/image-tracer-ts","gitHead":"a2a6bee7f69953653163fa8b6c43c1711c19251f","_id":"@image-tracer-ts/core@1.0.0","_nodeVersion":"18.12.1","_npmVersion":"8.19.2","dist":{"integrity":"sha512-BFUYXRlVVMk79qFgNFAVsyVZJYiyVfdu1nddlhWAjDNywqMfi0h/ZVm4cFIaaJGkHUmLsE7IqYZS5p0bMqJrog==","shasum":"44fe584fd09924625f62a3bfe13d544e52e43b38","tarball":"https://registry.npmjs.org/@image-tracer-ts/core/-/core-1.0.0.tgz","fileCount":44,"unpackedSize":512519,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFSTVACyEQeXHL9cyM9dakH62z2sRvT3OkoKtP63nOWDAiBz7ln9SPAVJg5plEKFA42fCm9uKI6arGhTimNvKPXWUg=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkK/BDACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpetw//c78Qfrevle7PNd9HdaA10uL0K8FXbGnmmd0Xr73LOa1eqUsy\r\nXNiJ8KxZufpHfat4dPvEoytDfDQGasZviQlDyxEJZlXxKIVlQf4k4lgwj3qS\r\nzSFxS9CDqW3nzG6a2HkkCM5QzU51N5idW+c+OsOmoj78PTN/1nw5BvwQ3LYB\r\nYMo+kyTCqf8/puOwoVCZjDMYFEfEWdajtTOD8t0bdzJzQ+/46dwIfiw9Sh1h\r\nrE4w1IIQ331IpWwqE0FqwPNsa2ezbGMh8icZc8p8CEcScj+S4PzQuaiF6sFd\r\nki6qbek2USHSRNLP1nSdXaNL1lwOvps4rWRRhdEVkq5LevNeUKDm5IzCxdyg\r\nld0dhCf5uRleZVTOpAY8tJ7+K5gAjCpR9xr4cfC/3j4x2YHZZ4DZgAFtuJ5b\r\nGX8AeDzN47Mukavrc3MMzH6spWrX6n5mUmh+JFKSxzYJ6E4c6c/3IYWFTIFa\r\nV9N7k8MSxzO6XF+KtwGvC153WCqjne+Cs3GHQUygtV+Mmlcoknx4jFkj2teZ\r\nn911zdQFQaSvYyc5oDw/qz6rw90f3siptBuKTWECIHxQxjerc3awrOXMCDOk\r\n4zj+sd9nDhmfqGTqQOrF49V7jdbqjeLfKtQ86OIsXANIau5FiUOT+VD25CVd\r\nqKN73s+yJWzI6/9dZ5Unjlsgf3FXlOaSQ6I=\r\n=VGTk\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"mringler","email":"m@mringler.net"},"directories":{},"maintainers":[{"name":"mringler","email":"m@mringler.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/core_1.0.0_1680601155590_0.8516528651022861"},"_hasShrinkwrap":false},"1.0.2":{"name":"@image-tracer-ts/core","version":"1.0.2","description":"Convert image bitmaps into SVG by tracing outlines. Typescript version of imagetracerjs. Use imagetracerts-nodejs or imagetracerts-browser for platform-specific file input and output.","scripts":{"clean":"rimraf ./dist/*","prepack":"npm run build","rollup":"rollup --config","build":"run-s clean rollup"},"prepare":"npm run build","author":{"name":"Moritz Ringler"},"license":"MIT","devDependencies":{"@rollup/plugin-replace":"^5.0.2"},"main":"dist/index.cjs","module":"dist/index.mjs","types":"dist/index.d.ts","keywords":["image","tracer","tracing","vector","raster","vectorize","vectorizing","convert","conversion","converting","tracing","bitmap","svg"],"bugs":{"url":"https://github.com/mringler/image-tracer-ts/issues"},"homepage":"https://github.com/mringler/image-tracer-ts","gitHead":"a2a6bee7f69953653163fa8b6c43c1711c19251f","_id":"@image-tracer-ts/core@1.0.2","_nodeVersion":"18.12.1","_npmVersion":"8.19.2","dist":{"integrity":"sha512-IY1/AMqvu6444dEwaFwJXwskp2fyKTFFVKvKHXBCT7hGz7OLRLHrWGHJrCsVw6HPSeucoHD5j/gtieWVSzocEw==","shasum":"3924713b816d02c421164cda028b46d87e58c819","tarball":"https://registry.npmjs.org/@image-tracer-ts/core/-/core-1.0.2.tgz","fileCount":45,"unpackedSize":518917,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQClAPlriIXmfooS7KdPMAp6En9oPVfoZubOruSiqZpMrgIhAPmhI98ZyYveL1eGKpk63MtuNKgmHKUIVooK9l9p+yHs"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkLBTFACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoRAw/+Ohs9fs0oGKxITgY2AY080zqNtdHxu19tof88VqvDi/PAk6Lt\r\nc9g8pguDQayhie3IKqBb3M5sbEX8ywPj3srKpaT4QyIDYUfxO3GvaE355b9j\r\noEG9IZOk8O8+hi5gRUl0vVIMHpQZrZ5KDfF2xnWoYXR4izMOitED2h6T1Qgv\r\nIpPQ7mr2D0f4lccO5c3/g6r2BUMFf6LA/d2YqvmfMfeHbDBCHkh/XWGbRq90\r\nJKaP/KyaGZgWhD50FfYU9E83XfTNVmSB0C1zeA7bdc2CTVa43l/c5qg0QBoe\r\nOUI91pZzk8q2gLJsh15ENbzJz99EE6XKy77DW3m45pbPZClaabuNmhEGd5am\r\nPQQoV1ZOisJuJIcjyr7hnbKsf+JTd+hzKGbc+pf/5ZvT50f9NUFvw1ta45+j\r\nGTRitkH0oR/rfJ8JQEvTfWxa+Se19lhc8ZnJMql/As2o+oVmiv3NJfdFt2Np\r\nc7TMP5VvfxQWmBgd9fkoCwxcDWHZr0wB8WskWzyhV+6LODNuGDYTnryGpw2u\r\nDBoH50ZTvBkwBrRuiRzzwE2Jh3hDg0IA9v3uB5iSiocTbyQkwTZbTmi7LHN7\r\n2G2930eI8HMOfIEzEW2YKd2FI3+eTRgOcp+tNH9IMrXP1r1heiy5y3e+0p61\r\n1/LHvpYrERi0t6ASuDFe52BiifyxYrZHmLQ=\r\n=MezR\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"mringler","email":"m@mringler.net"},"directories":{},"maintainers":[{"name":"mringler","email":"m@mringler.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/core_1.0.2_1680610501340_0.0736076923961444"},"_hasShrinkwrap":false}},"time":{"created":"2023-04-04T09:39:15.467Z","1.0.0":"2023-04-04T09:39:15.813Z","modified":"2023-04-04T12:15:01.753Z","1.0.2":"2023-04-04T12:15:01.623Z"},"maintainers":[{"name":"mringler","email":"m@mringler.net"}],"description":"Convert image bitmaps into SVG by tracing outlines. Typescript version of imagetracerjs. Use imagetracerts-nodejs or imagetracerts-browser for platform-specific file input and output.","homepage":"https://github.com/mringler/image-tracer-ts","keywords":["image","tracer","tracing","vector","raster","vectorize","vectorizing","convert","conversion","converting","tracing","bitmap","svg"],"author":{"name":"Moritz Ringler"},"bugs":{"url":"https://github.com/mringler/image-tracer-ts/issues"},"license":"MIT","readme":"#  @image-tracer-ts/core\n\n\nTrace images into SVG.\n\n![alt Bitmap to Svg](https://raw.githubusercontent.com/jankovicsandras/imagetracerjs/HEAD/docimages/s1.png)\n\n\nTypescript reimplementation of [imagetracer-js](https://www.npmjs.com/package/imagetracerjs).\n\nProvides ESM and CJS packages.\n\nThe core package only works with [ImageData](https://developer.mozilla.org/en-US/docs/Web/API/ImageData), use [@image-tracer-ts/browser](https://www.npmjs.com/package/@image-tracer-ts/browser) or [@image-tracer-ts/nodejs](https://www.npmjs.com/package/@image-tracer-ts/nodejs) to trace different image formats (like PNG, JPEG, etc) from different sources (files, buffers, URLs, etc).\n\n---\n\n## Basic Usage\n\n```\nimport { ImageTracer, Options } from '@image-tracer/core';\nconst options: Partial<Options> = {fillStyle: 'stroke'}\nconst tracer = new ImageTracer(options)\nconst svgString = tracer.traceImage(imageData, drawer)\n```\n\n---\n\n## Options\n\nTracing happens in four steps, each comes with several configuration options. Pass them in a configuration object, or as command line parameter, prefixed with `--` (i.e. `--blurRadius 5`). \n\n#### Step 1: Image preprocessing\n\nOptional steps to adjust image before processing.\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| blurRadius | number (between 0 and 5) | `0` (off) | Number of pixels (in each direction) to calculate the blurred pixel value from. |\n| blurDelta | number (0 - 4*255) | `20` | Maximum allowed difference between original pixel and blurred pixel when summing up RGBA values. If a blurred pixel exceeds delta, the original pixel is used instead. |\n| sharpen | boolean | `false` | Use sharpen filter |\n| sharpenThreshold | number (0 - 4*255) | `20` | Maximum allowed difference between original pixel and sharpened pixel when summing up RGBA values. If a sharpened pixel exceeds threshold, the original pixel is used instead. |\n\n#### Step 2:  Building a color index\nCreate a base palette and apply clustering to the pixels in the image to build color layer masks. \n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| colorSamplingMode | `generate` \\| `sample` \\| `scan` \\| `palette` | `scan` | Select how internal palette will be generated: <ul><li> <code>generate</code>: Generate colors along the spectrum independent of image colors. Builds a grayscale palette if less than 8 colors are requested.  </li><li> <code>sample</code>: Randomly access image for colors. </li><li> <code>scan</code>: Step through the image along a raster. </li><li> <code>palette</code>: Manually supply colors. </li></ul> |\n| palette | `Array<{r:number, g:number, b:number, a?:number}>` | `null` | Array of colors to use with `colorSamplingMode=palette` |\n| numberOfColors | number | `16` | Number of colors to be generated. |\n| colorClusteringCycles | number | `3` | Number of color clustering cycles. |\n| colorDistanceBuffering | `off` \\| `on` \\| `reasonable` | `reasonable` | Buffers color distances during clustering. Very efficient if palette has more than 30 colors. |\n| minColorQuota | number (between 0 and 1) | `0` (off) | Threshold for color pruning during color clustering. If ratio between pixels of a color and all pixels is below the given number, the color will be replaced by a random color. |\n\n\n#### Step 3: Tracing\n\nCreate vector data from pixels.\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| minShapeOutline | number | `0` (off)| Discard traced areas with an outline of less than the given number of points. |\n| interpolation | `off` \\| `interpolate` | `interpolate` | Sets interpolation mode. |\n| enhanceRightAngles | boolean | `true` | Do not interpolate right angles. |\n| lineErrorMargin | number | `1` | Line tracer error margin. Gives the squared maximum distance a point can be off a line trajectory to be still put on it. |\n| curveErrorMargin | number | `1` | Curve tracer error margin. Gives the squared maximum distance a point can be off a curved trajectory to be put on it. |\n\n#### Step 4: Drawing\nCreate SVG data from vectors. \n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| fillStyle | `fill` \\| `stroke` \\| `stroke+fill` | `stroke+fill` | Select how color segments are colored. |\n| strokeWidth | number | `1` | Stroke width written to SVG path. |\n| scale | number | `1` |  Multiply all coordinates by this number. |\n| decimalPlaces | number | `1` | Number of decimal places in svg values. |\n| viewBox | boolean | `true` | If enabled, the viewBox attribute will be set on the SVG tag element. |\n| trim | `off` \\| `ratio` \\| `all` | `off` | Removes empty border from the image. |\n| lineFilter | boolean | `false` | Do not draw lines (areas with less than 3 points). |\n| desc | boolean | `false` | Write a `desc` attribute to SVG edges with debug output |\n| segmentEndpointRadius | number | `0` (off) | Enables control output, draws white dots with given radius at segment borders. |\n| curveControlPointRadius | number | `0` (off) | Enables control output, draws curve control points as cyan dots with given radius.\n\n#### Misc\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| verbose | boolean | `false` | Write status data to console during trace. |\n| out | string | input file name + `.svg` | Set output file name (in ImageTracerNodejs) |\n| preset | see preset names below | null | Use preset from command line | \n\n### Named presets\n\nPreset configurations can be imported from the Options object:\n```\nimport { Options } from '@image-tracer/core';\nImageTracerBrowser.fromUrl<OutputType = string>(url, Options.Presets.posterized1)\n```\nFrom command line, the `--preset` parameter can be used along with a preset name:\n- `default`\n- `posterized1` `posterized2` `posterized3`\n- `curvy`\n- `sharp`\n- `detailed`\n- `smoothed`\n- `grayscale`\n- `fixedpalette`\n- `randomsampling1` `randomsampling2`\n- `artistic1` `artistic2` `artistic3` `artistic4`\n\n\n![Collection of example images for each preset](https://raw.githubusercontent.com/jankovicsandras/imagetracerjs/master/docimages/option_presets_small.png)\n\n---\n## Overriding the SVG Generator \n\nYou can provide a custom ImageDrawer to change how output is created from traced data:\n```\nconst drawer = new CustomizedImageDrawer()\nconst svgString = new ImageTracer(options).traceImage(imageData, drawer)\n```\n","readmeFilename":"README.md"}