pixon-image
v1.1.3
Published
Cross-platform, prebuilt, high-performance image processing library built on libvips
Readme
# Pixon
> A fast, native Node.js image processing library with chainable async APIs, inspired by Sharp.
Pixon is a lightweight, high-performance image manipulation library built on a C++ addon. It supports resizing, cropping, rotating, flipping, color adjustments, brightness enhancement, filters, and more — all via a simple, chainable API.
---
## Features
- Async, chainable image operations:
- Resize, Crop, Rotate
- Flip, Flop
- Adjust brightness, contrast, saturation
- Grayscale, Blur, Sharpen
- Composite images
- Rounded corners
- Supports JPEG, PNG, WEBP, and more
- Optional stream-based processing (currently file-based)
- High-performance native addon powered by C++
---
## Installation
### From npm
```bash
npm install pixon-imageThis will download a prebuilt binary if available for your OS, or compile the C++ addon automatically.
From source / GitHub
git clone https://github.com/sudiplahiri3123-alt/pixon.git
cd pixon
npm installUsage
Basic Example
const pixon = require('pixon-image');
(async () => {
const img = pixon('input.png');
await img.resize(600, 400);
await img.sharpen(1.0);
await img.adjust(10, 1.1, 1); // brightness, contrast, saturation
await img.roundCorners(6);
await img.toFile('output_final.jpg');
console.log('✅ Saved output: output_final.jpg');
})();Stream Example (File-Based)
const path = require('path');
const pixon = require('pixon-image');
(async () => {
const inputPath = path.join(__dirname, 'input.png');
const outputPath = path.join(__dirname, 'output_stream.jpg');
const img = pixon(inputPath);
await img.resize(400, 300);
await img.sharpen(1.5);
await img.grayscale();
await img.toFile(outputPath);
console.log(`✅ Image processed and saved: ${outputPath}`);
})();Benchmarking
You can measure performance of each operation using the included benchmark.js example:
node examples/benchmark.jsIt will print the time taken for each operation like resize, sharpen, adjust, etc.
API Reference
All methods are async and chainable:
| Method | Description |
| ---------------------------------------------------- | --------------------- |
| resize(width, height, crop = false) | Resize image |
| crop(left, top, width, height) | Crop image |
| rotate(angle) | Rotate image |
| flip() | Flip vertically |
| flop() | Flip horizontally |
| adjust(brightness, contrast, saturation) | Adjust image colors |
| colorfulEnhance() | Adjust to vibrant |
| brightnessEnhance() | Enhance brightness |
| removeColor() | Remove colors |
| softGray() | Soft grayscale effect |
| grayscale() | Convert to grayscale |
| blur(sigma) | Apply Gaussian blur |
| sharpen(sigma) | Sharpen image |
| composite(overlayPathOrBuffer, left, top, opacity) | Overlay another image |
| roundCorners(radius) | Apply rounded corners |
| toBuffer(format = '.jpg', quality = 90) | Get image as Buffer |
| toFile(outPath, format = '.jpg', quality = 90) | Save image to file |
Utilities
createRoundedMask(width, height, radius)— Create in-memory rounded corner mask (PNG buffer).
Stream Wrappers
createResizeStream,createCropStream,createRotateStream, etc.
Currently file-based; in-memory streaming coming soon.
Contributing
- Fork the repo
- Create your feature branch (
git checkout -b feature/my-feature) - Commit your changes (
git commit -am 'Add feature') - Push to the branch (
git push origin feature/my-feature) - Open a Pull Request
License
MIT © [Sudip Lahiri]
Notes
- Requires Node.js >= 16
- C++ build environment required for local compilation (
node-gypdependencies) - Prebuilt binaries will be added in future releases to simplify installation
Assets
Look at the examples/ directory for benchmark and test files using input.png.
input.png is free to use from Pexels.
Badges
Table of Contents
---