# express-cache-gm-image

> Express middleware to resize and crop pictures from url parameters with gm, cache and express.static

Latest version **1.0.1** (published 2017-10-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install express-cache-gm-image
pnpm add express-cache-gm-image
yarn add express-cache-gm-image
bun add express-cache-gm-image
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-10-04 |
| First published | 2016-08-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.10 |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Dmitriy Kiyatkin |
| Maintainers | dkiyatkin |
| Keywords | express, image, resize, gm, cache, static, middleware |

## Links

- npm: https://www.npmjs.com/package/express-cache-gm-image
- Repository: https://github.com/dkiyatkin/express-cache-gm-image
- Homepage: https://github.com/dkiyatkin/express-cache-gm-image#readme
- Issues: https://github.com/dkiyatkin/express-cache-gm-image/issues
- npm.io page: https://npm.io/package/express-cache-gm-image

## Dependencies (4)

- [gm](https://npm.io/package/gm.md) ^1.23.0
- [mime](https://npm.io/package/mime.md) ^2.0.3
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [express](https://npm.io/package/express.md) ^4.16.1

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2017-10-04
- 1.0.0 — 2017-10-03
- 0.0.4 — 2016-08-09
- 0.0.3 — 2016-08-09

## README

# express-cache-gm-image
Express middleware to resize and crop pictures from url parameters with gm, cache and express.static.

# Example
Url: `http://127.0.0.1:3000/images/example.png?w=50&h=100&r=1&c=2&f=1&y=20`

Node.js code:
```javascript
import express from 'express'

import ImageMiddleware from 'express-cache-gm-image'

const staticOptions = { // one settings for many static instances
  redirect: false,
  dotfiles: 'ignore',
  maxAge: 86400000
}

const app = express()

app.get('/*', ImageMiddleware({
  root: './public',
  cacheDir: './public/cache/imager',
  staticOptions: staticOptions,
  nextFunction: function (req, res) {
    return res.status(404).send('Not Found')
  }
}))

app.listen(3000, function () {
  console.log('Example app listening on port 3000!')
})
```

Nginx config:
```nginx
location ^~ /cache {
  deny all;
  return 404;
}

location ~* .(png|jpg|jpe?g)$ {
  root /var/www/site/cache/imager;
  if ($is_args = '') {
    root /var/www/site;
  }
  try_files /$args/$uri @node;
}
```

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