// effectified/packages · runtime · ▲ alpha

@effectified/sharp

sharp in Effect: a builder that is also a Node stream. Generated from its own types by the engine, and tested against the real library.

5
calls as Effects
1
tagged error
2
tests, real library
$ npm install --allow-remote=all https://effectified.dev/sharp.tgz effect

Always the newest release. To pin one, install its tarball from the releases.

// Examples

Code from its tests. Every one passes in CI.

Resize an image and read its metadata

test/facade.test.ts
import { sharp } from "@effectified/sharp";

const red = { create: { width: 4, height: 2, channels: 3, background: "#ff0000" } } as const;

const image = yield* sharp(red);
// The builder chain stays synchronous; toBuffer runs it, as an Effect.
const png = yield* image.resize(2, 1).png().toBuffer();
const metadata = yield* (yield* sharp(png)).metadata();
// API

What it offers. Read from upstream's types.

Exports: sharp.

HandleEffectsStreams and eventsReleased by
Sharpmetadata, stats, toBuffer, toFile, toUint8Array––
ErrorWhen
SharpErrorany other failure; codes ERR_DLOPEN_DISABLED
// Agent skill

For your coding agent. Ships in the package.

SKILL.md teaches an agent this facade: its rules, its API and these examples. It is in every release (node_modules/@effectified/sharp/SKILL.md); copy it into your agent's skills, or download it.

---
name: effectified-sharp
description: Write Effect code that uses sharp through @effectified/sharp. Use when an Effect program needs sharp, or code calling sharp moves onto Effect: what the facade offers, how its Effects, scopes and errors work, and tested examples.
---

# sharp through @effectified/sharp

A builder that is also a Node stream.

sharp in Effect: its async calls as Effects, its iterables as Streams, its resources scoped, its failures tagged. Generated from sharp's own types (this copy: 0.35.5+4, for sharp 0.35.5), so its types are upstream's and a call the facade does not change behaves as upstream documents.

## Install

```sh
pnpm add https://effectified.dev/sharp.tgz effect
```

## Rules

- Import from `@effectified/sharp`, not from `sharp`. sharp's types are `Upstream.<Type>` (`import { Upstream } from "@effectified/sharp"`).
- An async call returns an `Effect`, run with `yield*` inside `Effect.gen`; an async iterable is a `Stream`; a handle a call returns is a facade too. A synchronous call stays synchronous (a builder chain stays a chain).
- Failures are tagged: `SharpError`. Handle one with `Effect.catchTag("<Tag>", ...)`; each carries `operation` (`"<Handle>.<method>"`), `message`, upstream's `code` when it has one, and `cause`.
- What the facade does not wrap stays reachable: `.upstream` on every facade, `Upstream` for the package. Use them rather than importing `sharp` again.

## Examples

Each is code from a test that passes in CI.

### Resize an image and read its metadata

```ts
import { sharp } from "@effectified/sharp";

const red = { create: { width: 4, height: 2, channels: 3, background: "#ff0000" } } as const;

const image = yield* sharp(red);
// The builder chain stays synchronous; toBuffer runs it, as an Effect.
const png = yield* image.resize(2, 1).png().toBuffer();
const metadata = yield* (yield* sharp(png)).metadata();
```

From `test/facade.test.ts`.

## API

Exports: `sharp`.

| Error | From |
|---|---|
| `SharpError` | any other failure, codes `ERR_DLOPEN_DISABLED` |

| Handle | Effects | Streams | Events | Released by |
|---|---|---|---|---|
| `Sharp` | `metadata`, `stats`, `toBuffer`, `toFile`, `toUint8Array` | – | – | – |

More: https://effectified.dev/sharp