A cli tools of tinypng.
npm i -D untinyimgYou can use untiny command in your terminal
untiny -h # helpCompress a single image.
untiny ci ./test.pngCompress an array of images.
untiny cis ./test.png ./test2.pngCompress all images in the directory.
untiny cd ./test-cor--configyour config file path-kor--keyyour tinypng api key-oor--outyour output file path-dor--debugprint debug information
Create your untiny instance.
import { createUntiny } from 'untinyimg'
const untiny = createUntiny('your api key')Compress all images in the directory.
untiny.compressDir('your dir path of images')Compress all images with an array.
untiny.compressImages('your file path array of images')Compress a image.
untiny.compressImage('your file path of image')compressDir、compressImages、compressImage 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' | '*/*'