# Compress Images with Sharp

This is a Node.js module that allows you to compress images in a directory using the [Sharp](https://sharp.pixelplumbing.com/) image processing library. The module supports compressing images in the PNG, JPG, and JPEG formats.

## Installation

To use this module, you need to have Node.js installed on your system. You can install it from the official website: https://nodejs.org/

To install the module, run the following command in your terminal:

``` bash
npm install compress-images-with-sharp -D
```

## Usage № 1

To use the module, you need to import it into your Node.js project and call the `Compress` function, passing in the quality and directory parameters. The quality parameter is a number between 0 and 100 that specifies the quality of the compressed images. The directory parameter is a string that specifies the directory containing the images to be compressed.

Create a new file `compress.js` in the root directory of your project and add the following code:

```javascript
import { Compress } from 'compress-images-with-sharp';

Compress(80, 'static/assets');
```
or
```javascript
import { Compress, COMPRESS_TYPE } from 'compress-images-with-sharp';

Compress(80, 'static/assets', COMPRESS_TYPE.FULL);
```
```javascript
/**
 * COMPRESS_TYPE includes ORIGINAL | FULL | WEBP formats
 **/
```

Then add the script `"compress": "node compress.js"` to the `package.json` file so that you can run the compression from the command line:

```json
{
  "name": "my-project",
  "version": "1.0.0",
  "scripts": {
    "compress": "node compress.js"
  },
  "dependencies": {
    "compress-images-with-sharp": "^1.2.0"
  }
}
```

Now you can now run compression from the command line by running the compression command:

``` bash
npm run compress
```

## Usage № 2
Using the example of image compression using `npx`

```sh
npx compress-images-with-sharp 100 static/assets webp
```
or
```sh
npx compress-images-with-sharp 100 static/assets original
```
or
```sh
npx compress-images-with-sharp 100 static/assets full
```

## License

This module is licensed under the [MIT License](https://opensource.org/licenses/MIT).