# Image editor — library for developers

Data and helpers of the image editor: color palette, shapes, color conversion and named colors in 29 languages.

## Installation

```sh
npm install @openlibsdev/image-editor
```

```js
import ImageEditor from "https://cdn.jsdelivr.net/npm/@openlibsdev/image-editor@1.0.0/+esm";
```

## Usage

```js
import ImageEditor from "@openlibsdev/image-editor";

console.log(ImageEditor.toHex("rgb(13, 110, 253)"));   // "#0d6efd"
console.log(ImageEditor.hexA("#0d6efd", 0.5));
const color = await ImageEditor.findNamedColor("dark blue", "en");
```

## API

### `ImageEditor.toHex(c)`

Any CSS color → #rrggbb.

### `ImageEditor.hexA(hex, a)`

Color with transparency.

### `ImageEditor.PALETTE`

Default palette.

### `ImageEditor.SHAPES`

Shapes.

### `ImageEditor.starPoints()`

Points of a star shape.

### `ImageEditor.findNamedColor(text, lang)`

Finds a named color by its name in the given language ("dark blue" → #00008b).

### `ImageEditor.listNamedColors(lang)`

Lists the named colors with their names in the given language.

### `ImageEditor.EXTRA`

Names of the object properties saved with a project besides the standard ones (name, lock, id, blend mode).

### `ImageEditor.LBL`

Default layer names by object type (rectangle, ellipse, text, image, group, …).

### `ImageEditor.namedColorTexts(lang)`

Labels of the color field in the given language (the texts of the color picker), English for a missing language.

### `ImageEditor.textFontData`

Data for a text and font block: the font list, loading a font style, adding a font file, the block's labels in a language and the default values.

### `ImageEditor.APP`

Name and version of the library: {name, version}.

## Dependencies

- @imagemagick/magick-wasm 0.0.35 (Apache-2.0)
- @imagemagick/magick-wasm 0.0.35 (Apache-2.0)
- @simonwep/pickr 1.10.2 (MIT)
- @simonwep/pickr 1.10.2 (MIT)
- dejavu-fonts-ttf 2.37.3 (Bitstream Vera Fonts License (free, redistributable); DejaVu changes are public domain)
- fabric 5.3.0 (MIT)
- imagetracerjs 1.2.6 (Unlicense)
- jspdf 2.5.2 (MIT)

- GitHub: https://github.com/OpenLibsDev/image-editor
- npm: https://www.npmjs.com/package/@openlibsdev/image-editor
- Open the app: https://openlibs.dev/en/app/image-editor/
