https://github.com/josephden16/pic-shrink
pic-shrink is an easy-to-use CLI tool for compressing images in JPG, PNG, and WEBP.
https://github.com/josephden16/pic-shrink
cli image image-compression javascript nodejs sharp
Last synced: about 1 year ago
JSON representation
pic-shrink is an easy-to-use CLI tool for compressing images in JPG, PNG, and WEBP.
- Host: GitHub
- URL: https://github.com/josephden16/pic-shrink
- Owner: josephden16
- Created: 2023-07-15T04:25:33.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-25T14:23:03.000Z (almost 3 years ago)
- Last Synced: 2025-06-04T16:08:18.762Z (about 1 year ago)
- Topics: cli, image, image-compression, javascript, nodejs, sharp
- Language: TypeScript
- Homepage:
- Size: 1.46 MB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pic-shrink
pic-shrink is an easy-to-use CLI tool for compressing images in JPG, PNG, and WEBP.
## Prerequisites
- Node.js installed on your machine
## Installation
```shell
npm install -g pic-shrink
```
## Usage
To compress a single image file, you can use the following command:
```shell
pic-shrink
```
To compress multiple image files run the following command:
```shell
pic-shrink -i -o -c
```
Replace `` with the path to the directory containing the images you want to compress.
Replace `` with the optional path to the directory where you want to store the compressed images. If not provided, the compressed images will be stored in the same directory as the original images.
Replace `` with an optional value between 1 and 10 to specify the compression level for the images. Lower values result in higher compression and lower image quality, while higher values result in lower compression and higher image quality. If not provided, the default compression level of 7 will be used.
## Examples
Compress a single image file
```shell
pic-shrink image.jpg
```
Compress a single image file with a custom compression level
```shell
pic-shrink image.jpg -c 4
```
Compress images located in the "images" directory and store the compressed images in the same directory:
```shell
pic-shrink -i images
```
Compress images located in the "images" directory and store the compressed images in the "output" directory. If the "output" directory does not exist it will be created automatically:
```shell
pic-shrink -i images -o output
```
Compress images located in the "images" directory with a custom compression level:
```shell
pic-shrink -i images -c 5
```
## Notes
- Supported image formats: JPEG, PNG, and WebP.
- The CLI application uses the Node.js `sharp` package to perform image compression.
- Compressed images will be suffixed with "\_compressed" and stored in the specified or original directory.
- The compression level is optional, and if not provided, default values will be used.
**Please feel free to create issues for any bugs or unexpected behaviour you come across while using this tool.**