# weserv-sdk

> Unofficial weserv.nl SDK, a free image transformation service

Latest version **0.1.0** (published 2020-05-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install weserv-sdk
pnpm add weserv-sdk
yarn add weserv-sdk
bun add weserv-sdk
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2020-05-26 |
| First published | 2020-05-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 10.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | chamatt |
| Maintainers | chamatt |

## Links

- npm: https://www.npmjs.com/package/weserv-sdk
- npm.io page: https://npm.io/package/weserv-sdk

## Dependencies (2)

- [url-join](https://npm.io/package/url-join.md) ^4.0.1
- [@types/url-join](https://npm.io/package/@types/url-join.md) ^4.0.0

## Recent versions

- 0.1.0 (latest) — 2020-05-26

## README

# Weserv.nl SDK

### A javascript/typescript SDK for using weserv.nl image transformation service

## Example Usage 1
```typescript
import weserv, {Transform} from "./index"

const original = "https://images.weserv.nl/puppy.jpg"

const config: Transform = { 
    w: 1000, 
    h: 1000, 
    fit: "cover", 
    a: "attention", 
    mask: "heart"
}

const transformed = weserv.transform(original, config)
// https://images.weserv.nl?url=images.weserv.nl%2Fpuppy.jpg&w=1000&h=1000&fit=cover&a=attention&mask=heart
```
|Original|Transformed|
|--|--|
 ![](https://images.weserv.nl/puppy.jpg)| ![](https://images.weserv.nl?url=images.weserv.nl%2Fpuppy.jpg&w=1000&h=1000&fit=cover&a=attention&mask=heart)

## Documentation

You can see the full documentation here: [Weserv.nl Docs](https://images.weserv.nl/docs)

The config arguments for the SDK are basically the same as the query strings from the documentation. 

## Exceptions

For queries that require multiple parameters to be passed at the same time (e.g. &ch=300&cw=300&cx=300&cy=300), you would use it like this:

List of properties affected by this:
- Rectangular crop 
    - From
    ```typescript
    "&ch=300&cw=300&cx=300&cy=300"
    ```
    - To
     ```typescript
     {
        // ...other transformations
        c: {
            x: 300,
            y: 300,
            w: 300,
            h: 300
        }
    }
     ```
- Focal Alignment

    - From
    ```typescript
    "&a=focal-0-20"
    ```
    - To
  ```typescript
     {
        // ...other transformations
        a: {
            x: 0,
            y: 20,
        }
    }
     ```

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