npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pikpix

v1.4.2

Published

A command-line tool to convert and optimize image formats with optional compression and resizing.

Downloads

32

Readme

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.