DEV Community

Cover image for Pixon: A Fast, Native Image Processing Command-Line Tool
Sudip Lahiri
Sudip Lahiri

Posted on

Pixon: A Fast, Native Image Processing Command-Line Tool

Summary

Pixon is a high-performance, native image-processing command-line tool built for speed, predictability, and cross-platform use. It supports common image operations such as resizing, cropping, rotation, flipping, color adjustments, blurring, sharpening, alpha-channel modifications, and image compositing.

Built in C++ using OpenCV, Pixon provides a chainable CLI that lets you run multiple transformations in a single command. The tool is language-agnostic and works smoothly with Python, Node.js, Go, and shell-based workflows. Its reproducible and extensible design makes it a good fit for automated pipelines, backend services, and large-scale image-processing tasks.


Statement of Need

Image processing is a core component of many modern software pipelines, including web applications, media servers, continuous integration workflows, and AI/ML preprocessing systems. In practice, existing solutions often involve trade-offs:

  • High-level libraries provide ease of use but can introduce performance overhead and memory inefficiencies at scale.
  • Low-level native tools offer superior performance but are harder to integrate, automate, and maintain across heterogeneous environments.

Pixon bridges this gap by providing native performance with simple integration, chainable operations, and predictable behavior. Its architecture minimizes intermediate file I/O, streamlines automation, and ensures consistent results across platforms and programming languages.


Implementation

Architecture

  • Language: C++
  • Core Library: OpenCV

Design Principles

  • Single, self-contained binary
  • Chainable command-line operations
  • Works across languages (Python, Node.js, Go, shell workflows)
  • Minimal overhead and deterministic execution

Features

  • Resize, crop, rotate, flip, and flop images
  • Adjust brightness, contrast, and saturation
  • Blur and sharpen images
  • Composite multiple images
  • Add or remove alpha channels
  • Extend canvas and trim transparent edges
  • Export to PNG, JPEG, or WebP
  • Chain multiple operations in a single command

Cross-Language Integration

Pixon can be called from any environment that can run system commands, making it easy to integrate with Python, Node.js, Go, shell scripts, or other programming languages.

Python

import subprocess

# Path to input image (adjust if needed)
input_file = "input.png"
output_file = "output.jpeg"

# Run Pixon CLI
result = subprocess.run([
    "pixon",
    input_file,
    "resize", "400", "300", "0",
    output_file
], capture_output=True, text=True)

# Print stdout and stderr
print("STDOUT:\n", result.stdout)
print("STDERR:\n", result.stderr)

# Check return code
if result.returncode == 0:
    print(f"Success! Output saved to {output_file}")
else:
    print(f"Failed with return code {result.returncode}")
Enter fullscreen mode Exit fullscreen mode

Node.js

const { execFile } = require('child_process');

const inputFile = 'input.png';
const outputFile = 'output.jpeg';

execFile(
    'pixon',
    [inputFile, 'resize', '400', '300', '0', outputFile],
    (error, stdout, stderr) => {
        if (error) {
            console.error('Error:', error.message);
            console.error('STDERR:', stderr);
            return;
        }

        console.log('STDOUT:', stdout);

        if (stderr) {
            console.warn('Warnings:', stderr);
        }

        console.log(`Success! Output saved to ${outputFile}`);
    }
);

Enter fullscreen mode Exit fullscreen mode

Go

package main

import (
    "fmt"
    "os"
    "os/exec"
)

func main() {
    inputFile := "input.png"
    outputFile := "output.jpeg"

    cmd := exec.Command("pixon", inputFile, "resize", "400", "300", "0", outputFile)

    // Combine stdout and stderr
    out, err := cmd.CombinedOutput()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error executing pixon: %v\n", err)
        fmt.Fprintf(os.Stderr, "Output:\n%s\n", string(out))
        os.Exit(1)
    }

    fmt.Printf("Pixon output:\n%s\n", string(out))
    fmt.Printf("Success! Output saved to %s\n", outputFile)
}

Enter fullscreen mode Exit fullscreen mode

Quality Control

  • Unit tests cover all image operations
  • Chainable workflows are tested for correctness and reproducibility
  • Minimal external dependencies keep installation simple
  • Continuous integration ensures testing across all supported platforms

Performance and Benchmarking

Benchmarks were conducted using a representative test image. Outputs were saved under pixon/test/benchmark_outputs/.

Single Operation Benchmark

Operation Time (seconds)
Resize 0.856
Rotate 0.967
Crop 0.808
Blur 1.084
Sharpen 0.974
Flip 1.022
Flop 1.036
Composite 1.060
Color Adjust 1.052
Add Alpha 3.151
Remove Alpha 1.278
Extend Canvas 1.107
Trim 3.564

Multiple Operations Benchmark

Operations Chain Time (seconds)
Resize → Sharpen → Color Adjust → Flip → Composite 0.710

Observations

  • Most individual operations finish in under 1.1 seconds
  • Alpha addition and trimming are slower due to extra memory use and pixel-level processing
  • Chaining multiple operations in a single command improves performance by reducing intermediate file I/O
  • Overall, these results highlight the efficiency of Pixon’s command architecture for automated workflows

Availability

Operating Systems

  • Linux (x64): Fully supported
  • Linux (ARM): Experimental
  • macOS: Experimental
  • Windows: Not officially supported, but works via WSL

Programming Languages

  • Native: C++
  • Integration via system calls: Python, Node.js, Go, Shell

Installation

For installation instructions, please refer to the GitHub repository:

👉 https://github.com/sudiplahiri3123-alt/pixon

License

Pixon uses the Pixon Source-Available License (PSAL) v2.0.

See the GitHub repository for full license terms.

Reuse Potential

Pixon is designed to be flexible and reusable across a wide range of projects, including:

  • Automated image processing pipelines
  • Backend services for web and mobile applications
  • AI/ML preprocessing workflows
  • Educational and research projects in computer vision

The architecture is extensible, making it easy for contributors to add new filters, transformations, or platform support.

References

Figures and Tables

Example Output

Original image

Original image vs. blurred using Pixon:

pixon input.png blur 3 blur.jpeg
Enter fullscreen mode Exit fullscreen mode


pixon input.png blur 15 blur.jpeg
Enter fullscreen mode Exit fullscreen mode

Original image vs. Resize → Sharpen → Color Adjust using Pixon:

pixon input.png resize 400 300 0 sharpen coloradjust 0.1 1.2 1.3 output.jpeg
Enter fullscreen mode Exit fullscreen mode

Original image vs. extend → Sharpen → Color Adjust using Pixon:

pixon input.png extend 5 5 5 5 sharpen coloradjust 0.2 1.1 1.0 output.jpeg
Enter fullscreen mode Exit fullscreen mode

Original image vs. composite using Pixon:

pixon input.png composite overlay.png 50 50 0.7 composite.jpeg
Enter fullscreen mode Exit fullscreen mode

Architecture Overview

👉 GitHub Repository:

https://github.com/sudiplahiri3123-alt/pixon

Top comments (0)