1.0.2 ⢠Published 6 months ago
pic-press v1.0.2
šø Node Image Compressor
A simple and lightweight Node.js package for compressing images using the sharp
library.
š Features
ā
Easy to use
ā
Supports JPEG compression
ā
CLI support for quick compression
ā
Works in both Node.js applications and command-line tools
š¦ Installation
Install Globally (for CLI use)
npm install -g pic-press
Now you can use the compress
command in your terminal.
Install Locally (for Node.js projects)
npm install pic-press
š§ Usage
1ļøā£ Using CLI
Run the following command to compress an image:
compress <inputPath> <outputPath> [quality]
- ā Path to the input image.
- ā Path to save the compressed image.
- quality ā Compression quality (default: 80, range: 1-100).
Example
compress input.jpg output.jpg 70
This will compress input.jpg
to output.jpg
with 70% quality.
2ļøā£ Using in a Node.js Project
import the package
const { compressImage } = require("pic-press");
Example code:
const { compressImage } = require("pic-press");
const inputPath = "input.jpg";
const outputPath = "compressed.jpg";
const quality = 75;
compressImage(inputPath, outputPath, quality)
.then(() => console.log("Compression successful!"))
.catch((err) => console.error("Error:", err));
š Requirements
- Node.js v12 or later.
sharp
package (installed automatically).
š License
This project is licensed under the MIT License.
š” Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request.
š¬ Support
If you encounter any issues, please open an issue on GitHub. Happy Coding! š
---
### **Next Steps**
- Replace `your-username` with your GitHub username in the links.
- Once your package is published, update the actual **npm URL** in the badges.
Let me know if you want any changes! š