# @itkyk/minify-images

> ## install ```bash $ npm i -D @itkyk/minify-images ```

Latest version **1.0.7** (published 2023-03-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install @itkyk/minify-images
pnpm add @itkyk/minify-images
yarn add @itkyk/minify-images
bun add @itkyk/minify-images
```

Provides the command `minify`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2023-03-08 |
| First published | 2022-06-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 8 |
| Unpacked size | 59 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Takayuki Inoue |
| Maintainers | i_takayuki |
| Keywords | minify, optimize, image, jpeg, png, svg, typescript |

## Links

- npm: https://www.npmjs.com/package/@itkyk/minify-images
- Homepage: https://github.com/itkyk/minify-images#readme
- Issues: https://github.com/itkyk/minify-images/issues
- npm.io page: https://npm.io/package/@itkyk/minify-images

## Dependencies (8)

- [glob](https://npm.io/package/glob.md) ^8.0.3
- [svgo](https://npm.io/package/svgo.md) ^2.8.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^10.1.0
- [commander](https://npm.io/package/commander.md) ^9.3.0
- [deepmerge](https://npm.io/package/deepmerge.md) ^4.2.2
- [@types/svgo](https://npm.io/package/@types/svgo.md) ^2.6.3
- [@squoosh/lib](https://npm.io/package/@squoosh/lib.md) ^0.4.0
- [is-plain-object](https://npm.io/package/is-plain-object.md) ^5.0.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.7 (latest) — 2023-03-08
- 1.0.6 — 2022-08-01
- 1.0.5 — 2022-07-06
- 1.0.4 — 2022-07-06
- 1.0.3 — 2022-07-06
- 1.0.2 — 2022-06-21
- 1.0.1 — 2022-06-20
- 1.0.0 — 2022-06-20

## README

# @itkyk/minify-images

## install
```bash
$ npm i -D @itkyk/minify-images
```

## CLI
```bash
minify -i ./inputDir/to/path -o outputDir/to/path
```

### Options
| key | description |
|------|----------------|
| -i, --input | The path of the directory containing the images you want to compress. |
| -o, --output | Directory path to export the compressed image |
| -m, --mozjpeg |compression settings for mozjpeg |
| -ox, --oxipng | compression settings for oxipng |
| -q, --quant | compression settings for quant |

## API
```typescript
import Minify, {ImageMinOptionInterface} from "@itkyk/minify-images";

const options: ImageMinOptionInterface = {
  inputPath: "inputDir/to/path",
  outputPath: "outputDir/to/Path",
  encodeOptions: {
    mozjpeg: {},
    oxipng: {},
    quant: {}
  }
}

new Minify(options);
```

### Options
| key | description |
|------|----------------|
| inputPath | The path of the directory containing the images you want to compress. |
| outputPath | Directory path to export the compressed image |
| mozjpeg |compression settings for mozjpeg |
| oxipng | compression settings for oxipng |
| quant | compression settings for quant |


## DefaultOption
### moxjpeg
```typescript
const defaultMozJpegOpts = {
  quality: 75,
  baseline: false,
  arithmetic: false,
  progressive: true,
  optimize_coding: true,
  smoothing: 0,
  color_space: 3,
  quant_table: 3,
  trellis_multipass: false,
  trellis_opt_zero: false,
  trellis_opt_table: false,
  trellis_loops: 1,
  auto_subsample: true,
  chroma_subsample: 2,
  separate_chroma_quality: false,
  chroma_quality: 75,
};
```

### oxipng
```typescript
export const defaultOxipngOpts = {
  level: 3,
  interlace: false,
};
```

### quant
```typescript
const defaultQuantOpts = {
  enabled: true,
  zx: 0,
  maxNumColors: 256,
  dither: 1,
};
```

### svgo
```typescript
const defaultSVGOOpts = [
  {
    name: "removeAttrs",
    params: {
      attrs: "data-name",
    },
  },
];
```

## Attention
The moxjpeg and oxipng options merge with the default options, but svgo drowns out the default options and overwrites them.

```typescript
const options = {
  encodeOptions: {
    mozjpeg: {}, // The default options apply.
    oxipng: {}, // The default options apply.
    svgo: [] // The default options are overwritten on the empty array.
  }
}
```

---
_Source: https://npm.io/package/@itkyk/minify-images · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
