Socket
Socket
Sign inDemoInstall

ipx

Package Overview
Dependencies
126
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ipx

[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href]


Version published
Weekly downloads
256K
increased by2.67%
Maintainers
1
Install size
34.1 MB
Created
Weekly downloads
 

Readme

Source

🖼️ IPX

npm version npm downloads

High performance, secure and easy to use image proxy based on sharp and libvips.

Using CLI

You can use ipx command to start server using:

npx ipx@latest

The default server directory is the current working directory.

Programatic API

You can use IPX as a middleware or directly use IPX interface.

import { createIPX, createIPXMiddleware } from "ipx";

const ipx = createIPX({ domains: ["unjs.io"] });

// (req, res) => void
const ipxMiddleware = createIPXMiddleware(ipx);

Example: Using with unjs/h3:

import { createIPX, createIPXMiddleware } from "ipx";
import { listen } from "listhen";
import { createApp, fromNodeMiddleware, toNodeListener } from "h3";

const ipx = createIPX({});
const ipxMiddleware = createIPXMiddleware(ipx);

const app = createApp().use("/", fromNodeMiddleware(ipxMiddleware));

listen(toNodeListener(app));

Example: Using express:

import { createIPX, createIPXMiddleware } from "ipx";
import { listen } from "listhen";
import express from "express";

const ipx = createIPX({});
const ipxMiddleware = createIPXMiddleware(ipx);

const app = express().use("/", ipxMiddleware);

listen(app);

Examples

Get original image:

/_/static/buffalo.png

Change format to webp and keep other things same as source:

/f_webp/static/buffalo.png

Keep original format (png) and set width to 200:

/w_200/static/buffalo.png

Resize to 200x200px using embed method and change format to webp:

/embed,f_webp,s_200x200/static/buffalo.png

Modifiers

PropertyDocsExampleComments
width / wDocs/width_200/buffalo.png
height / hDocs/height_200/buffalo.png
resize / sDocs/s_200x200/buffalo.png
kernelDocs/s_200x200,kernel_nearest/buffalo.pngSupported kernel: nearest, cubic, mitchell, lanczos2 and lanczos3 (default).
fitDocs/s_200x200,fit_outside/buffalo.pngSets fit option for resize.
position / posDocs/s_200x200,pos_top/buffalo.pngSets position option for resize.
trimDocs/trim_100/buffalo.png
extendDocs/extend_{top}_{right}_{bottom}_{left}/buffalo.pngExtend / pad / extrude one or more edges of the image with either the provided background colour or pixels derived from the image.
background / b_/r_45,b_00ff00/buffalo.png
extractDocs/extract_{left}_{top}_{width}_{height}/buffalo.pngExtract/crop a region of the image.
format / fDocs/format_webp/buffalo.pngSupported format: jpg, jpeg, png, webp, avif, gif, heif, tiff and auto (experimental only with middleware)
quality / q_/quality_50/buffalo.pngAccepted values: 0 to 100
rotateDocs/rotate_45/buffalo.png
enlarge_/enlarge,s_2000x2000/buffalo.pngAllow 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.
flipDocs/flip/buffalo.png
flopDocs/flop/buffalo.png
sharpenDocs/sharpen_30/buffalo.png
medianDocs/median_10/buffalo.png
blurDocs/blur_5/buffalo.png
gammaDocs/gamma_3/buffalo.png
negateDocs/negate/buffalo.png
normalizeDocs/normalize/buffalo.png
thresholdDocs/threshold_10/buffalo.png
tintDocs/tint_1098123/buffalo.png
grayscaleDocs/grayscale/buffalo.png
animated-/animated/buffalo.gifExperimental

Config

Config can be customized using IPX_* environment variables.

  • IPX_DIR

    • Default: . (current working directory)
  • IPX_DOMAINS

    • Default: []
  • IPX_MAX_AGE

    • Default: 300
  • IPX_ALIAS

    • Default: {}
  • IPX_FETCH_OPTIONS

    • Default: {}

License

MIT

FAQs

Last updated on 02 Oct 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc