IPX
![Package Size](https://flat.badgen.net/packagephobia/install/ipx)
High performance, secure and easy to use image proxy based on sharp and libvips.
Usage
Quick Start
You can use ipx
command to start server using:
$ npx ipx
Programatic Usage
You can use IPX as a Connect/Express middleware or directly use ipx api.
import { createIPX, createIPXMiddleware } from 'ipx'
const ipx = createIPX()
const app = express()
app.use('/image', createIPXMiddleware(ipx))
Examples
Change format to webp
and keep other things same as source:
http://cdn.example.com/static/buffalo.png?format=webp
Keep original format (png
) and set width to 200
:
http://cdn.example.com/static/buffalo.png?width=200
Resize to 200x300px
using embed
method and change format to webp
:
http://cdn.example.com/static/buffalo.png?embed&format=webp&size=200x300
Modifiers
Modifier | Arguments | Example | Description |
---|
s | width , height | s_200_300 | Resize image. |
w | width | w_200 | Change image with. |
h | height | h_200 | Change image height. |
max | - | max | Preserving aspect ratio, resize the image to be as large as possible while ensuring its dimensions are less than or equal to the width and height specified. |
min | - | min | Preserving aspect ratio, resize the image to be as small as possible while ensuring its dimensions are greater than or equal to the width and height specified. |
Config
Config can be customized using IPX_*
environment variables.
-
IPX_LOCAL_DIR
- Default:
.
(current working directory)
-
IPX_REMOTE_ACCEPT
License
MIT