0.0.3 • Published 1 year ago

untinyimg v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

untinyimg npm

A cli tools of tinypng.

Usage

npm i -D untinyimg

Cli

You can use untiny command in your terminal

untiny -h # help

untiny help

untiny ci

Compress a single image.

untiny ci ./test.png

untiny cis

Compress an array of images.

untiny cis ./test.png ./test2.png

untiny cd

Compress all images in the directory.

untiny cd ./test

untiny cli options

  • -c or --config your config file path
  • -k or --key your tinypng api key
  • -o or --out your output file path
  • -d or --debug print debug information

Api

createUntiny

Create your untiny instance.

import { createUntiny } from 'untinyimg'

const untiny = createUntiny('your api key')

compressDir

Compress all images in the directory.

untiny.compressDir('your dir path of images')

compressImages

Compress all images with an array.

untiny.compressImages('your file path array of images')

compressImage

Compress a image.

untiny.compressImage('your file path of image')

types

compressDircompressImagescompressImage support options in second param.

export interface CompressOption {
  /**
   * convert file path to return a new file path
   * @param originPath origin file path
   * @param originImgName origin file name
   * @returns new file path
   */
  handler?: (originPath: string, originImgName: string) => string

  /**
   * Your desired image types. The following options are available as a type:
   */
  convertType?: IMG_TYPE | IMG_TYPE[]

  /**
   * The transform object specifies the stylistic transformations that will be applied to your image
   */
  transform?: string

  /**
   * Whether to print debug information
   * @default true
   */
  debug?: boolean
}

export type IMG_EXT = '.png' | '.jpg' | '.jpeg' | '.webp'

export type IMG_TYPE = 'image/png' | 'image/jpeg' | 'image/webp' | 'image/jpg' | '*/*'

License

MIT License © 2023 zyyv

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago