ipx 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,7 @@
1
- # IPX
1
+ # 🖼️ IPX
2
2
 
3
- [![NPM Vernion](https://flat.badgen.net/npm/v/ipx)](https://www.npmjs.com/package/ipx)
4
- [![NPM Downloads](https://flat.badgen.net/npm/dt/ipx)](https://www.npmjs.com/package/ipx)
5
- [![Package Size](https://flat.badgen.net/packagephobia/install/ipx)](https://packagephobia.now.sh/result?p=ipx)
3
+ [![npm version][npm-version-src]][npm-version-href]
4
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
6
5
 
7
6
  High performance, secure and easy to use image proxy based on [sharp](https://github.com/lovell/sharp) and [libvips](https://github.com/libvips/libvips).
8
7
 
@@ -32,50 +31,50 @@ app.use("/image", createIPXMiddleware(ipx));
32
31
 
33
32
  ### Examples
34
33
 
35
- > The examples assume that a `static` folder with `buffalo.png` file is present in the directory where IPX server is running.
36
-
37
34
  Get original image:
38
35
 
39
- `http://localhost:3000/_/static/buffalo.png`
36
+ `/_/static/buffalo.png`
40
37
 
41
38
  Change format to `webp` and keep other things same as source:
42
39
 
43
- `http://localhost:3000/f_webp/static/buffalo.png`
40
+ `/f_webp/static/buffalo.png`
44
41
 
45
42
  Keep original format (`png`) and set width to `200`:
46
43
 
47
- `http://localhost:3000/w_200/static/buffalo.png`
44
+ `/w_200/static/buffalo.png`
48
45
 
49
46
  Resize to `200x200px` using `embed` method and change format to `webp`:
50
47
 
51
- `http://localhost:3000/embed,f_webp,s_200x200/static/buffalo.png`
48
+ `/embed,f_webp,s_200x200/static/buffalo.png`
52
49
 
53
50
  ### Modifiers
54
51
 
55
- | Property | Docs | Example | Comments |
56
- | --------------- | :-------------------------------------------------------------- | :---------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
57
- | width / w | [Docs](https://sharp.pixelplumbing.com/api-resize#resize) | `http://localhost:3000/width_200/buffalo.png` |
58
- | height / h | [Docs](https://sharp.pixelplumbing.com/api-resize#resize) | `http://localhost:3000/height_200/buffalo.png` |
59
- | resize / s | [Docs](https://sharp.pixelplumbing.com/api-resize#resize) | `http://localhost:3000/s_200x200/buffalo.png` |
60
- | fit | [Docs](https://sharp.pixelplumbing.com/api-resize#resize) | `http://localhost:3000/s_200x200,fit_outside/buffalo.png` | Sets `fit` option for `resize`.
61
- | position / pos | [Docs](https://sharp.pixelplumbing.com/api-resize#resize) | `http://localhost:3000/s_200x200,pos_top/buffalo.png` | Sets `position` option for `resize`.
62
- | trim | [Docs](https://sharp.pixelplumbing.com/api-resize#trim) | `http://localhost:3000/trim_100/buffalo.png` |
63
- | format | [Docs](https://sharp.pixelplumbing.com/api-output#toformat) | `http://localhost:3000/format_webp/buffalo.png` | Supported format: `jpg`, `jpeg`, `png`, `webp`, `avif`, `gif`, `heif` |
64
- | quality / q | \_ | `http://localhost:3000/quality_50/buffalo.png` | Accepted values: 0 to 100 |
65
- | rotate | [Docs](https://sharp.pixelplumbing.com/api-operation#rotate) | `http://localhost:3000/rotate_45/buffalo.png` |
66
- | enlarge | \_ | `http://localhost:3000/enlarge,s_2000x2000/buffalo.png` | Allow the image to be upscaled. By default the returned image will never be larger than the source in any dimension, while preserving the requested aspect ratio. |
67
- | flip | [Docs](https://sharp.pixelplumbing.com/api-operation#flip) | `http://localhost:3000/flip/buffalo.png` |
68
- | flop | [Docs](https://sharp.pixelplumbing.com/api-operation#flop) | `http://localhost:3000/flop/buffalo.png` |
69
- | sharpen | [Docs](https://sharp.pixelplumbing.com/api-operation#sharpen) | `http://localhost:3000/sharpen_30/buffalo.png` |
70
- | median | [Docs](https://sharp.pixelplumbing.com/api-operation#median) | `http://localhost:3000/median_10/buffalo.png` |
71
- | blur | [Docs](https://sharp.pixelplumbing.com/api-operation#blur) | `http://localhost:3000/blur_5/buffalo.png` |
72
- | gamma | [Docs](https://sharp.pixelplumbing.com/api-operation#gamma) | `http://localhost:3000/gamma_3/buffalo.png` |
73
- | negate | [Docs](https://sharp.pixelplumbing.com/api-operation#negate) | `http://localhost:3000/negate/buffalo.png` |
74
- | normalize | [Docs](https://sharp.pixelplumbing.com/api-operation#normalize) | `http://localhost:3000/normalize/buffalo.png` |
75
- | threshold | [Docs](https://sharp.pixelplumbing.com/api-operation#threshold) | `http://localhost:3000/threshold_10/buffalo.png` |
76
- | tint | [Docs](https://sharp.pixelplumbing.com/api-colour#tint) | `http://localhost:3000/tint_1098123/buffalo.png` |
77
- | grayscale | [Docs](https://sharp.pixelplumbing.com/api-colour#grayscale) | `http://localhost:3000/grayscale/buffalo.png` |
78
- | animated | - | `http://localhost:3000/animated/buffalo.gif` | Experimental |
52
+ | Property | Docs | Example | Comments |
53
+ | -------------- | :-------------------------------------------------------------- | :--------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
54
+ | width / w | [Docs](https://sharp.pixelplumbing.com/api-resize#resize) | `/width_200/buffalo.png` |
55
+ | height / h | [Docs](https://sharp.pixelplumbing.com/api-resize#resize) | `/height_200/buffalo.png` |
56
+ | resize / s | [Docs](https://sharp.pixelplumbing.com/api-resize#resize) | `/s_200x200/buffalo.png` |
57
+ | fit | [Docs](https://sharp.pixelplumbing.com/api-resize#resize) | `/s_200x200,fit_outside/buffalo.png` | Sets `fit` option for `resize`. |
58
+ | position / pos | [Docs](https://sharp.pixelplumbing.com/api-resize#resize) | `/s_200x200,pos_top/buffalo.png` | Sets `position` option for `resize`. |
59
+ | trim | [Docs](https://sharp.pixelplumbing.com/api-resize#trim) | `/trim_100/buffalo.png` |
60
+ | extend | [Docs](https://sharp.pixelplumbing.com/api-resize#extend) | `/extend_{top}_{right}_{bottom}_{left}/buffalo.png` | Extend / pad / extrude one or more edges of the image with either the provided background colour or pixels derived from the image. |
61
+ | extract | [Docs](https://sharp.pixelplumbing.com/api-resize#extract) | `/extract_{left}_{top}_{width}_{height}/buffalo.png` | Extract/crop a region of the image. |
62
+ | format / f | [Docs](https://sharp.pixelplumbing.com/api-output#toformat) | `/format_webp/buffalo.png` | Supported format: `jpg`, `jpeg`, `png`, `webp`, `avif`, `gif`, `heif`, `tiff` and `auto` (experimental only with middleware) |
63
+ | quality / q | \_ | `/quality_50/buffalo.png` | Accepted values: 0 to 100 |
64
+ | rotate | [Docs](https://sharp.pixelplumbing.com/api-operation#rotate) | `/rotate_45/buffalo.png` |
65
+ | enlarge | \_ | `/enlarge,s_2000x2000/buffalo.png` | Allow the image to be upscaled. By default the returned image will never be larger than the source in any dimension, while preserving the requested aspect ratio. |
66
+ | flip | [Docs](https://sharp.pixelplumbing.com/api-operation#flip) | `/flip/buffalo.png` |
67
+ | flop | [Docs](https://sharp.pixelplumbing.com/api-operation#flop) | `/flop/buffalo.png` |
68
+ | sharpen | [Docs](https://sharp.pixelplumbing.com/api-operation#sharpen) | `/sharpen_30/buffalo.png` |
69
+ | median | [Docs](https://sharp.pixelplumbing.com/api-operation#median) | `/median_10/buffalo.png` |
70
+ | blur | [Docs](https://sharp.pixelplumbing.com/api-operation#blur) | `/blur_5/buffalo.png` |
71
+ | gamma | [Docs](https://sharp.pixelplumbing.com/api-operation#gamma) | `/gamma_3/buffalo.png` |
72
+ | negate | [Docs](https://sharp.pixelplumbing.com/api-operation#negate) | `/negate/buffalo.png` |
73
+ | normalize | [Docs](https://sharp.pixelplumbing.com/api-operation#normalize) | `/normalize/buffalo.png` |
74
+ | threshold | [Docs](https://sharp.pixelplumbing.com/api-operation#threshold) | `/threshold_10/buffalo.png` |
75
+ | tint | [Docs](https://sharp.pixelplumbing.com/api-colour#tint) | `/tint_1098123/buffalo.png` |
76
+ | grayscale | [Docs](https://sharp.pixelplumbing.com/api-colour#grayscale) | `/grayscale/buffalo.png` |
77
+ | animated | - | `/animated/buffalo.gif` | Experimental |
79
78
 
80
79
  ### Config
81
80
 
@@ -86,8 +85,36 @@ Config can be customized using `IPX_*` environment variables.
86
85
  - Default: `.` (current working directory)
87
86
 
88
87
  - `IPX_DOMAINS`
88
+
89
89
  - Default: `[]`
90
90
 
91
+ - `IPX_MAX_AGE`
92
+
93
+ - Default: `300`
94
+
95
+ - `IPX_ALIAS`
96
+
97
+ - Default: `{}`
98
+
99
+ - `IPX_FETCH_OPTIONS`
100
+
101
+ - Default: `{}`
102
+
91
103
  ## License
92
104
 
93
- MIT
105
+ [MIT](./LICENSE)
106
+
107
+ <!-- Badges -->
108
+
109
+ [npm-version-src]: https://img.shields.io/npm/v/ipx?style=flat&colorA=18181B&colorB=F0DB4F
110
+ [npm-version-href]: https://npmjs.com/package/ipx
111
+ [npm-downloads-src]: https://img.shields.io/npm/dm/ipx?style=flat&colorA=18181B&colorB=F0DB4F
112
+ [npm-downloads-href]: https://npmjs.com/package/ipx
113
+ [github-actions-src]: https://img.shields.io/github/workflow/status/unjs/ipx/ci/main?style=flat&colorA=18181B&colorB=F0DB4F
114
+ [github-actions-href]: https://github.com/unjs/ipx/actions?query=workflow%3Aci
115
+ [codecov-src]: https://img.shields.io/codecov/c/gh/unjs/ipx/main?style=flat&colorA=18181B&colorB=F0DB4F
116
+ [codecov-href]: https://codecov.io/gh/unjs/ipx
117
+ [bundle-src]: https://img.shields.io/bundlephobia/minzip/ipx?style=flat&colorA=18181B&colorB=F0DB4F
118
+ [bundle-href]: https://bundlephobia.com/result?p=ipx
119
+ [license-src]: https://img.shields.io/github/license/unjs/ipx.svg?style=flat&colorA=18181B&colorB=F0DB4F
120
+ [license-href]: https://github.com/unjs/ipx/blob/main/LICENSE
package/dist/cli.cjs CHANGED
@@ -2,16 +2,17 @@
2
2
 
3
3
  const consola = require('consola');
4
4
  const listhen = require('listhen');
5
- const middleware = require('./shared/ipx.e9f7a9b5.cjs');
5
+ const index = require('./index.cjs');
6
6
  require('defu');
7
7
  require('image-meta');
8
8
  require('ufo');
9
9
  require('node:fs');
10
10
  require('pathe');
11
+ require('destr');
11
12
  require('node:http');
12
13
  require('node:https');
13
14
  require('node-fetch-native');
14
- require('destr');
15
+ require('@fastify/accept-negotiator');
15
16
  require('etag');
16
17
  require('xss');
17
18
 
@@ -20,9 +21,9 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
20
21
  const consola__default = /*#__PURE__*/_interopDefaultCompat(consola);
21
22
 
22
23
  async function main() {
23
- const ipx = middleware.createIPX({});
24
- const middleware$1 = middleware.createIPXMiddleware(ipx);
25
- await listhen.listen(middleware$1, {
24
+ const ipx = index.createIPX({});
25
+ const middleware = index.createIPXMiddleware(ipx);
26
+ await listhen.listen(middleware, {
26
27
  clipboard: false
27
28
  });
28
29
  }
package/dist/cli.mjs CHANGED
@@ -1,15 +1,16 @@
1
1
  import consola from 'consola';
2
2
  import { listen } from 'listhen';
3
- import { c as createIPX, a as createIPXMiddleware } from './shared/ipx.cc3515c9.mjs';
3
+ import { createIPX, createIPXMiddleware } from './index.mjs';
4
4
  import 'defu';
5
5
  import 'image-meta';
6
6
  import 'ufo';
7
7
  import 'node:fs';
8
8
  import 'pathe';
9
+ import 'destr';
9
10
  import 'node:http';
10
11
  import 'node:https';
11
12
  import 'node-fetch-native';
12
- import 'destr';
13
+ import '@fastify/accept-negotiator';
13
14
  import 'etag';
14
15
  import 'xss';
15
16