# blitline-resizer

> Resizes images using Blitline

Latest version **0.2.3** (published 2015-05-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install blitline-resizer
pnpm add blitline-resizer
yarn add blitline-resizer
bun add blitline-resizer
```

## Health

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

Positive: no vulnerabilities.

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

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.3 |
| Published | 2015-05-25 |
| First published | 2015-01-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+4 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Gregor MacLennan |
| Maintainers | gmaclennan, digidem |
| Keywords | blitline, image, resize |

## Links

- npm: https://www.npmjs.com/package/blitline-resizer
- Repository: https://github.com/digidem/blitline-resizer
- Homepage: https://github.com/digidem/blitline-resizer#readme
- Issues: https://github.com/digidem/blitline-resizer/issues
- npm.io page: https://npm.io/package/blitline-resizer

## Dependencies (6)

- [url](https://npm.io/package/url.md) ^0.10.2
- [xtend](https://npm.io/package/xtend.md) ^4.0.0
- [request](https://npm.io/package/request.md) ^2.53.0
- [validator](https://npm.io/package/validator.md) ^3.27.0
- [mime-types](https://npm.io/package/mime-types.md) ^2.0.7
- [simple_blitline_node](https://npm.io/package/simple_blitline_node.md) git://github.com/gmaclennan/simple_blitline_node.git

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 0.2.3 (latest) — 2015-05-25
- 0.2.2 — 2015-03-01
- 0.2.1 — 2015-03-01
- 0.2.0 — 2015-02-28
- 0.1.0 — 2015-02-28
- 0.0.1 — 2015-01-08

## README

[![Build Status](https://travis-ci.org/digidem/blitline-resizer.svg)](https://travis-ci.org/digidem/blitline-resizer)

Blitline Image Resizer
======================

Resizes images using [Blitline](https://www.blitline.com/). Takes an array of image urls and an array of sizes and will copy all resized images to an Amazon S3 bucket. Right now sizes are for fit to width. Images need to be online and publicly accessible.

## Why?

Created for resizing images for use on responsive websites, hence for now only fits width.

## Usage

1. [Create a Blitline account](https://www.blitline.com/signup) and get a valid Application Id (a developer account is free).

2. [Set up permissions](https://www.blitline.com/docs/s3_permissions) on an Amazon S3 bucket so that Blitline can put the results there.

3. If you submit a postbackUrl you will need a server that can receive and process the [postback](https://www.blitline.com/docs/postback) (think webhook) that Blitline posts to when image processing is complete.

If you set `options.postbackUrl` then `resize()` will return an array of hashes with job_id according to https://www.blitline.com/docs/api#returnData - one job for each image you submit.

If you do not set `options.postbackUrl` then it should return an array of results for each image as described http://www.blitline.com/docs/postback - this is not guaranteed though, the request can timeout. Using a postbackUrl is more reliable.

```javascript
var config = {
    blitlineAppId: 'YOUR_BLITLINE_APP_ID',
    postbackUrl: 'http://valid.url/to/receive/postback',
    s3Bucket: 'AMAZON_S3_BUCKET_NAME'
}

var resize = require('blitline-resizer')(config);

var options = {
    images: [ 'array', 'of', 'valid', 'image', 'urls'],
    sizes: [ 100, 200 ] // array of widths to resize to
}

resize(options, function(err, response) {
    console.log(response);
    // responds with a hash or results with job_ids see https://www.blitline.com/docs/api
}
```

## Tests

Needs the following environment variables set:

```sh
BLITLINE_APP_ID=_your blitline app id_
S3_KEY=_s3 key ID for test user_
S3_SECRET=_s3 secret key for test user_
S3_BUCKET=_test s3 bucket_ # NB. Blitline should have PutObject permissions, your S3 test user should have DeleteObject permissions
```

`npm test`

## Todo

- [x] Better test coverage
- [x] Support [polling](https://www.blitline.com/docs/polling) to avoid needing postback server
- [ ] Allow resizing to fit both height and width

## Changelog

### v0.2.1

Can set secret on initial config, rather than each task

### v0.2.0

Support for long polling without a postback

### v0.1.0

Add `options.retina` to also create retina versions of images. Defaults to false. **NB. Breaking change** previously it created retina versions by default.

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