What is ipx?
The ipx npm package is an image processing server that allows you to manipulate images on-the-fly. It supports various image transformations such as resizing, cropping, and format conversion, making it useful for web applications that need dynamic image processing.
What are ipx's main functionalities?
Resizing Images
This feature allows you to resize images to specified dimensions. In the code sample, the image is resized to a width of 300 pixels and a height of 200 pixels.
const ipx = require('ipx')();
const url = '/_ipx/w_300,h_200/image.jpg';
const result = await ipx(url);
Cropping Images
This feature allows you to crop images to specified dimensions. In the code sample, the image is cropped to a width of 300 pixels and a height of 200 pixels.
const ipx = require('ipx')();
const url = '/_ipx/c_crop,w_300,h_200/image.jpg';
const result = await ipx(url);
Format Conversion
This feature allows you to convert images to different formats. In the code sample, the image is converted to the WebP format.
const ipx = require('ipx')();
const url = '/_ipx/f_webp/image.jpg';
const result = await ipx(url);
Other packages similar to ipx
sharp
Sharp is a high-performance image processing library that supports resizing, cropping, and format conversion. It is known for its speed and efficiency, making it a popular choice for server-side image processing. Compared to ipx, sharp is more of a low-level library that requires more manual setup and configuration.
jimp
Jimp is a JavaScript image processing library that supports various image manipulations such as resizing, cropping, and format conversion. It is easy to use and does not require any external dependencies. Compared to ipx, Jimp is more suitable for client-side applications and smaller projects.
gm
GraphicsMagick (gm) is a Node.js wrapper for the GraphicsMagick and ImageMagick image processing libraries. It supports a wide range of image manipulations and is highly configurable. Compared to ipx, gm offers more advanced features but requires the installation of external software.
🖼 IPX
High performance, secure and easy to use and image proxy based on Sharp and libvips.
WARNING:: THIS PROJECT AND DOCS ARE STILL WIP!
Project goals
- Fast and minimal as possible.
- Configurable operations.
- Built-in secure cache with human readable entries and resistant against duplicates.
- Remote agnostic cache and input adapters.
- Smart and auto cache cleaning.
API
/{format}/{operations}/{src}
Example: http://cdn.example.com/webp/w:200/avatars/bafollo.png
ََUse _
value in place for {format}
or {operations}
to keep original values of source image.
Possible values for format: jpeg
,webp
or png
.
Operations
Operation | Arguments | Example | Description |
---|
f | format | f:webp | Change format. |
s | width , height | s:200:300 | Resize image. |
w | width | w:200 | Change image with. |
h | height | h:200 | Change image height. |
embed | - | embed | Preserving aspect ratio, resize the image to the maximum width or height specified then embed on a background of the exact width and height specified. |
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. |
License
MIT - Pooya Parsa