Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize TypeScript exports #87

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 39 additions & 39 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
export interface Options { // eslint-disable-line @typescript-eslint/consistent-type-definitions
type Options = {
/**
Speed `10` has 5% lower quality, but is about 8 times faster than the default. Speed `11` disables dithering and lowers compression level.

Values: `1` (brute-force) to `11` (fastest)

@default 3
*/
* Speed `10` has 5% lower quality, but is about 8 times faster than the default. Speed `11` disables dithering and lowers compression level.
* Values: `1` (brute-force) to `11` (fastest)
* @default 3
*/
speed?: number;

/**
Remove optional metadata.

@default false
*/
* Remove optional metadata.
* @default false
*/
strip?: boolean;

/**
Instructs pngquant to use the least amount of colors required to meet or exceed the max quality. If conversion results in quality below the min quality the image won't be saved.

Min and max are numbers in range 0 (worst) to 1 (perfect), similar to JPEG.

Values: `[0...1, 0...1]`

@example [0.3, 0.5]
*/
* Instructs pngquant to use the least amount of colors required to meet or exceed the max quality. If conversion results in quality below the min quality the image won't be saved.
* Min and max are numbers in range 0 (worst) to 1 (perfect), similar to JPEG.
* Values: `[0...1, 0...1]`
* @example [0.3, 0.5]
*/
quality?: [number, number];

/**
Set the dithering level using a fractional number between 0 (none) and 1 (full).

Pass in `false` to disable dithering.

Values: 0...1

@default 1
*/
* Set the dithering level using a fractional number between 0 (none) and 1 (full).
* Pass in `false` to disable dithering.
* Values: 0...1
* @default 1
*/
dithering?: number | boolean;

/**
Truncate number of least significant bits of color (per channel).

Use this when image will be output on low-depth displays (e.g. 16-bit RGB). pngquant will make almost-opaque pixels fully opaque and will reduce amount of semi-transparent colors.
*/
* Truncate number of least significant bits of color (per channel).
* Use this when image will be output on low-depth displays (e.g. 16-bit RGB). pngquant will make almost-opaque pixels fully opaque and will reduce amount of semi-transparent colors.
*/
posterize?: number;
}

/**
* Print verbose status messages.
* @default false
*/
verbose?: boolean;
};

/**
Image data to optimize.
*/
export type Plugin = (input: Uint8Array) => Promise<Uint8Array>;
* Buffer or stream to optimize.
* @info Banned type Buffer has been replaced in Imagemin >=8.0.1 with Uint8Array, must stick to it.
* @see https://sindresorhus.com/blog/goodbye-nodejs-buffer [@typescript-eslint/ban-types]
* @see https://github.com/imagemin/imagemin/compare/v8.0.1...main
*/
type Plugin = (input: Uint8Array | NodeJS.ReadableStream) => Promise<Uint8Array>;

/**
Imagemin plugin for pngquant.
* Imagemin plugin for pngquant.
* @returns An Imagemin plugin.
*/
declare function imageminPngquant(options?: Options): Plugin;

@returns An Imagemin plugin.
*/
export default function imageminPngquant(options?: Options): Plugin;
export {type Options, type Plugin, imageminPngquant};
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "imagemin-pngquant",
"version": "10.0.0",
"version": "11.0.0",
"description": "Imagemin plugin for `pngquant`",
"license": "MIT",
"repository": "imagemin/imagemin-pngquant",
Expand Down Expand Up @@ -37,6 +37,9 @@
"pngquant-bin": "^9.0.0",
"uint8array-extras": "^1.1.0"
},
"peerDependencies": {
"imagemin": "^8.0.1"
},
"devDependencies": {
"@types/node": "^20.12.10",
"ava": "^6.1.3",
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ npm install imagemin-pngquant

### Prerequisites

> **Linux** machines must have the following packages prior to install: `libpng-dev libimagequant-dev`
> **Linux** machines must have the following packages prior to install: `libpng-dev libimagequant-dev`

```sh
sudo apt-get -y install libpng-dev libimagequant-dev
Expand All @@ -20,7 +20,7 @@ sudo apt-get -y install libpng-dev libimagequant-dev

```js
import imagemin from 'imagemin';
import imageminPngquant from 'imagemin-pngquant';
import { imageminPngquant } from 'imagemin-pngquant';

await imagemin(['images/*.png'], {
destination: 'build/images',
Expand Down
Loading