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 +62 -35
- package/dist/cli.cjs +6 -5
- package/dist/cli.mjs +3 -2
- package/dist/index.cjs +661 -18
- package/dist/index.d.ts +131 -11
- package/dist/index.mjs +651 -12
- package/package.json +11 -9
- package/dist/shared/ipx.cc3515c9.mjs +0 -616
- package/dist/shared/ipx.e9f7a9b5.cjs +0 -628
package/README.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
# IPX
|
|
1
|
+
# 🖼️ IPX
|
|
2
2
|
|
|
3
|
-
[](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
|
-
|
|
36
|
+
`/_/static/buffalo.png`
|
|
40
37
|
|
|
41
38
|
Change format to `webp` and keep other things same as source:
|
|
42
39
|
|
|
43
|
-
|
|
40
|
+
`/f_webp/static/buffalo.png`
|
|
44
41
|
|
|
45
42
|
Keep original format (`png`) and set width to `200`:
|
|
46
43
|
|
|
47
|
-
|
|
44
|
+
`/w_200/static/buffalo.png`
|
|
48
45
|
|
|
49
46
|
Resize to `200x200px` using `embed` method and change format to `webp`:
|
|
50
47
|
|
|
51
|
-
|
|
48
|
+
`/embed,f_webp,s_200x200/static/buffalo.png`
|
|
52
49
|
|
|
53
50
|
### Modifiers
|
|
54
51
|
|
|
55
|
-
| Property
|
|
56
|
-
|
|
|
57
|
-
| width / w
|
|
58
|
-
| height / h
|
|
59
|
-
| resize / s
|
|
60
|
-
| fit
|
|
61
|
-
| position / pos
|
|
62
|
-
| trim
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
|
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
|
|
|
76
|
-
|
|
|
77
|
-
|
|
|
78
|
-
|
|
|
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
|
|
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('
|
|
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 =
|
|
24
|
-
const middleware
|
|
25
|
-
await listhen.listen(middleware
|
|
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 {
|
|
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 '
|
|
13
|
+
import '@fastify/accept-negotiator';
|
|
13
14
|
import 'etag';
|
|
14
15
|
import 'xss';
|
|
15
16
|
|