# imagetracer

> Simple raster image tracer and vectorizer written in TypeScript.

Latest version **0.2.2** (published 2023-02-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install imagetracer
pnpm add imagetracer
yarn add imagetracer
bun add imagetracer
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2023-02-08 |
| First published | 2022-06-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 87.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | MuRong |
| Maintainers | murongxdb |

## Links

- npm: https://www.npmjs.com/package/imagetracer
- Repository: https://github.com/murongg/imagetracer
- Homepage: https://github.com/murongg/imagetracer#readme
- Issues: https://github.com/murongg/imagetracer/issues
- Funding: https://github.com/sponsors/murongg
- npm.io page: https://npm.io/package/imagetracer

## Recent versions

- 0.2.2 (latest) — 2023-02-08
- 0.2.1 — 2022-06-30
- 0.2.0 — 2022-06-29
- 0.1.3 — 2022-06-29
- 0.1.2 — 2022-06-29
- 0.1.0 — 2022-06-29
- 0.0.1 — 2022-06-28

## README

# imagetracer

[![NPM version](https://img.shields.io/npm/v/imagetracer?color=a1b858&label=)](https://www.npmjs.com/package/imagetracer)

## 📎 Installation
```sh
$ npm install imagetracer
```
## 👽 Usage

```js
import { imageTracer } from 'imagetracer'
const svg = imageTracer.imageToSVG(imageUrl)
```



## API
| Function name              | Arguments                                              | Returns              | Run type                       |
| -------------------------- | ------------------------------------------------------ | -------------------- | ------------------------------ |
| ```imageToSVG```           | `url: string, options: ImageTracerOptionsParamers`     | `Promise<string> `   | Asynchronous, Browser only     |
| ```imageDataToSVG```       | `imgd: ImageData, options: ImageTracerOptionsParamers` | `string`             | Synchronous, Browser & Node.js |
| ```imageToTracedata```     | `url: string, options: ImageTracerOptionsParamers`     | `Promise<Tracedata>` | Asynchronous, Browser only     |
| ```imageDataToTracedata``` | `imgd: ImageData, options: ImageTracerOptionsParamers` | `Tracedata`          | Synchronous, Browser & Node.js |

```imagedata``` is standard [ImageData](https://developer.mozilla.org/en-US/docs/Web/API/ImageData) here, ```canvas``` is [canvas](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas) .

### Helper Functions (Browser only)
| Function name         | Arguments                                       | Returns                                                                         | Run type                   |
| --------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------- | -------------------------- |
| ```appendSVGString``` | `svgstr: string, parentid: string`              | Nothing, an SVG will be appended to the container DOM element with id=parentid. | Synchronous, Browser only  |
| ```loadImage```       | `url: string, options: MaybeImageTracerOptions` | `Promise<HTMLCanvasElement>`                                                    | Asynchronous, Browser only |
| ```getImgdata```      | `canvas: HTMLCanvasElement`                     | `ImageData`                                                                     | Synchronous, Browser only  |

There are more functions for advanced users, read the source if you are interested. :)

"Browser only" means that Node.js doesn't have built-in canvas and DOM support as of 2018, so loading an image to an ImageData object needs an external library. 

## Options
You can use an option preset name (string) or an [options object](https://github.com/murongg/imagetracer/blob/master/options.md) to control the tracing and rendering process.

![Option presets gallery](https://github.com/murongg/imagetracer/blob/main/assets/option_presets_small.jpg?raw=true)

These strings can be passed instead of the options object:
```'default'```
```'posterized1'```
```'posterized2'```
```'posterized3'```
```'curvy'```
```'sharp'```
```'detailed'```
```'smoothed'```
```'grayscale'```
```'fixedpalette'```
```'randomsampling1'```
```'randomsampling2'```
```'artistic1'```
```'artistic2'```
```'artistic3'```
```'artistic4'```

[Read more about options.](https://github.com/murongg/imagetracer/blob/master/options.md)

---
_Source: https://npm.io/package/imagetracer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
