# blurhash-as

> Blurhash algorithm implementation in AssemblyScript

Latest version **0.10.0** (published 2023-03-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install blurhash-as
pnpm add blurhash-as
yarn add blurhash-as
bun add blurhash-as
```

## 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.10.0 |
| Published | 2023-03-03 |
| First published | 2021-06-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 1 |
| Unpacked size | 1.5 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 31 |
| Author | Alexis Munsayac |
| Maintainers | lxsmnsyc |
| Keywords | blurhash, wasm, webassembly, assemblyscript |

## Links

- npm: https://www.npmjs.com/package/blurhash-as
- Repository: https://github.com/lxsmnsyc/blurhash-as
- Homepage: https://github.com/lxsmnsyc/blurhash-as/tree/main/packages/blurhash-as
- Issues: https://github.com/lxsmnsyc/blurhash-as/issues
- npm.io page: https://npm.io/package/blurhash-as

## Dependencies (1)

- [@assemblyscript/loader](https://npm.io/package/@assemblyscript/loader.md) ^0.27.0

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 0.10.0 (latest) — 2023-03-03
- 0.9.1 — 2022-01-24
- 0.9.0 — 2021-10-18
- 0.8.0 — 2021-08-30
- 0.7.0 — 2021-08-29
- 0.6.0 — 2021-08-25
- 0.5.0 — 2021-08-23
- 0.4.0 — 2021-07-08
- 0.3.0 — 2021-07-01
- 0.2.1 — 2021-06-30
- 0.2.0 — 2021-06-30
- 0.1.4 — 2021-06-30
- 0.1.3 — 2021-06-30
- 0.1.2 — 2021-06-30
- 0.1.1 — 2021-06-30
- … 1 more at https://npm.io/package/blurhash-as/versions

## README

# blurhash-as

> Blurhash implementation in AssemblyScript

[![NPM](https://img.shields.io/npm/v/blurhash-as.svg)](https://www.npmjs.com/package/blurhash-as) [![JavaScript Style Guide](https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript) [![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?style=flat-square&logo=codesandbox)](https://codesandbox.io/s/github/lxsmnsyc/blurhash-as/tree/main/examples/vite-blurhash-demo)

## Install

```bash
npm install --save blurhash-as
```

```bash
yarn add blurhash-as
```

## Usage

```ts
import * as blurhash from 'blurhash-as';

// Initialize the wasm module, optional
blurhash.init().then(() => {
  console.log('Initialized!');
});

// Encode image data
const hash = await blurhash.encode(imageData, width, height, xComponent, yComponent);

// Decode hash
const imageData = await blurhash.decode(hash, width, height, punch);
// You can also use any values for width and height, it is recommended
// to use a dimension with the same aspect ratio as your component dimensions.

// Generate a CSS sheet
const sheet = await blurhash.toCSSSheet(hash, displayWidth, displayHeight, punch);

// Or generate a Style Object
const style = await blurhash.toCSSObject(hash, displayWidth, displayHeight, punch);

// Or generate an SVG string
const svg = await blurhash.toSVG(hash, displayWidth, displayHeight, punch);
```

### Browser

For browser context, you'll have to use `blurhash-as/browser`. The API is the same as `blurhash-as` with the inclusion of `setURL` for identifying the target WASM file. `setURL` is required to be called as-early-as-possible before using the provided `blurhash` functions.

Example in Vite:

```ts
import * as blurhash from 'blurhash-as/browser';
import wasmURL from 'blurhash-as/build/optimized.wasm?url';

blurhash.setURL(wasmURL);
```

## Sponsors

![Sponsors](https://github.com/lxsmnsyc/sponsors/blob/main/sponsors.svg?raw=true)

## License

MIT © [lxsmnsyc](https://github.com/lxsmnsyc)

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