open-index/open-npm huggingface dataset:
npm package: @kittl/little-cms
Description: Upstream repository: [Little-CMS](https://github.com/mm2/Little-CMS)   Website: [www.littlecms.com](https://www.littlecms.com)
Latest version: 1.0.2

# Little-CMS binding for JavaScript

Upstream repository: [Little-CMS](https://github.com/mm2/Little-CMS)  
Website: [www.littlecms.com](https://www.littlecms.com)

JavaScript / TypeScript bindings for **LittleCMS (lcms2)** compiled to **WebAssembly**.

Supports Node.js and browsers.

---

## Installation

```bash
npm install @kittl/little-cms
```

## Initialization

Before using the API, initialize the WASM runtime:

```ts
import { initWasm } from "littlecms";

await initWasm();
```

You can also install an optional error handler:

```ts
import { cmsSetLogErrorHandler } from "littlecms";

cmsSetLogErrorHandler((code, message) => {
  console.error(code, message);
});
```

## Examples

### Create an sRGB profile

Create a built-in sRGB ICC profile:

```ts
import { cmsCreate_sRGBProfile, cmsCloseProfile } from "littlecms";

const profile = cmsCreate_sRGBProfile();

if (profile.value) {
  cmsCloseProfile(profile.value);
}
```

### Load an ICC profile

Load an ICC profile from memory.

```ts
import { readFileSync } from "fs";
import { cmsOpenProfileFromMem, cmsCloseProfile } from "littlecms";

const bytes = new Uint8Array(readFileSync("./profile.icc"));
const profile = cmsOpenProfileFromMem(bytes);

if (profile.value) {
  cmsCloseProfile(profile.value);
}
```

### Read profile information

Read metadata from an ICC profile.

```ts
import { cmsGetProfileInfoASCII, CmsPrintInfoType } from "littlecms";

const info = cmsGetProfileInfoASCII(profile.value, CmsPrintInfoType.Description, "en", "US");

console.log(info.value);
```

### Color transform

Create a color transform and convert pixel data between color spaces.

```ts
import {
  cmsCreateTransform,
  cmsDoTransform,
  cmsDeleteTransform,
  CmsIntent,
  TYPE_RGB_8,
  TYPE_CMYK_8,
  FLAGS_IDENTITY
} from "littlecms";

const transform = cmsCreateTransform(
  srgbProfile,
  TYPE_RGB_8,
  cmykProfile,
  TYPE_CMYK_8,
  CmsIntent.RelativeColorimetric,
  FLAGS_IDENTITY
);

const result = cmsDoTransform(
  transform.value,
  new Uint8Array([
    255,255,255,
    0,0,0,
    235,235,235,
    234,22,21
  ]),
  4,
);

cmsDeleteTransform(transform.value);
```

## Build

Build the TypeScript bindings and WebAssembly output:

```bash
pnpm build
```