pic-press
v1.0.2
Published
A simple Node.js package to compress images using sharp.
Maintainers
Readme
📸 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-pressNow 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] (optional) → Compression quality (default: 80, range: 1-100).
Example
compress input.jpg output.jpg 70This 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.
sharppackage (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! 🚀