pikpix

1.4.2 • Public • Published

PikPix

PikPix is a versatile command-line tool designed to convert and optimize image formats with optional compression, resizing and optimizations. To learn more about the technologies used to build PikPix, refer to the Acknowledgements section at the bottom of this README.

Features

  • Image Conversion: Supports various formats including heic, heif, avif, jpeg, jpg, png, raw, tiff, tif, webp, gif, jp2, jpx, j2k, j2c, and svg.
  • Compression Level: Specify compression level (quality) for formats like jpeg, jpg, png, webp, tiff, heif, heic, and avif.
  • Advanced Compression:
    • Lossless Compression: Apply lossless compression for supported formats.
    • Progressive JPEG: Apply progressive compression for JPEG images.
    • Chroma Subsampling: Specify chroma subsampling rate (e.g., 4:2:0, 4:4:4).
    • Adaptive Quantization: Apply adaptive quantization for better compression.
    • Region of Interest (ROI) Compression: Apply compression to specified regions of the image.
  • Resizing: Resize images to specified dimensions without cropping.
  • Handling Local and Remote Images: Input images from local file paths, URLs, and directories.
  • Directory Processing: Process all images in a specified directory.
  • Unique Output File Names: Ensures output file names are unique to avoid overwriting.
  • Optimization Options: Various optimization features including flattening, sharpening, denoising, converting to grayscale, and applying blur.
  • Error Handling: Comprehensive error handling with clear error messages.
  • Version Output: Displays the current version of the tool.

Installation

To install PikPix, use npm:

npm install -g pikpix

Usage

pikpix -i <input> -o <output> -f <format> [options]

Options

  • -v, --version: Output the current version.
  • -i, --input <path>: Input image file, URL, or directory.
  • -o, --output <path>: Output image file or directory.
  • -f, --format <format>: Output format (heic, heif, avif, jpeg, jpg, png, raw, tiff, tif, webp, gif, jp2, jpx, j2k, j2c, svg).
  • -c, --compression <level>: Compression level (0-100).
  • -r, --resize <dimensions>: Resize dimensions in format WIDTHxHEIGHT or WIDTHXHEIGHT.
  • --flatten [color]: Flatten the image and fill the background with the specified color (default: white).
  • --sharpen: Apply sharpening to the image.
  • --denoise: Apply denoising to the image.
  • --grayscale: Convert the image to grayscale.
  • --blur <sigma>: Apply blur with the specified sigma value.
  • --lossless: Apply lossless compression if supported by the format.
  • --progressive: Apply progressive compression for JPEG images.
  • --subsample <rate>: Apply chroma subsampling rate (e.g., 4:2:0, 4:4:4).
  • --adaptive-quantization: Apply adaptive quantization for better compression.
  • --roi-compression <regions>: Apply region of interest (ROI) compression to specified regions.

Examples

Convert a Single Image

pikpix -i input.jpg -o output.png -f png

Convert and Compress an Image

pikpix -i input.jpg -o output.webp -f webp -c 80

Resize an Image

pikpix -i input.jpg -o output.png -f png -r 800x600

Optimize an Image

pikpix -i input.jpg -o output.png -f png --sharpen --grayscale

Process a Directory of Images

pikpix -i ./input-directory -o ./output-directory -f webp -c 80

Development

Setup

Clone the repository and install dependencies:

git clone https://github.com/tcj9/pikpix.git
cd pikpix
npm install

Test Locally

Link the package locally to test it:

npm link

You can now use the pikpix command from anywhere in your terminal.

Unlink After Testing

To unlink the package after testing:

npm unlink

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Steps to Contribute

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Commit your changes.
  4. Push the branch to your fork.
  5. Submit a Pull Request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Author

TCJ9

Issues

If you encounter any issues, please open an issue.

Acknowledgements

  • Sharp - The high-performance Node.js image processing library.
  • Commander - The complete solution for Node.js command-line interfaces.
  • Axios - Promise based HTTP client for the browser and Node.js.
  • File-Type - Detect the file type of a Buffer/Uint8Array/ArrayBuffer.
  • Progress - Flexible ascii progress bar for Node.js.

Package Sidebar

Install

npm i pikpix

Weekly Downloads

50

Version

1.4.2

License

MIT

Unpacked Size

1.07 MB

Total Files

9

Last publish

Collaborators

  • tcj9