{"id":23430717,"url":"https://github.com/zauni/pngmin","last_synced_at":"2025-10-26T11:36:12.455Z","repository":{"id":7489296,"uuid":"8838240","full_name":"zauni/pngmin","owner":"zauni","description":"Grunt plugin to compress png images with pngquant.","archived":false,"fork":false,"pushed_at":"2024-09-24T06:00:53.000Z","size":979,"stargazers_count":25,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T23:14:32.346Z","etag":null,"topics":["grunt-plugin","gruntjs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zauni.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-03-17T17:26:18.000Z","updated_at":"2024-09-24T06:00:50.000Z","dependencies_parsed_at":"2024-06-18T18:24:52.314Z","dependency_job_id":"7f9149e2-4639-4165-8a04-d336ef34adf5","html_url":"https://github.com/zauni/pngmin","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zauni%2Fpngmin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zauni%2Fpngmin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zauni%2Fpngmin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zauni%2Fpngmin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zauni","download_url":"https://codeload.github.com/zauni/pngmin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248643007,"owners_count":21138355,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["grunt-plugin","gruntjs"],"created_at":"2024-12-23T09:46:33.704Z","updated_at":"2025-10-26T11:36:07.412Z","avatar_url":"https://github.com/zauni.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grunt-pngmin\n\n\u003ca href=\"https://github.com/zauni/pngmin/actions/workflows/ci.yml\"\u003e\u003cimg src=\"https://github.com/zauni/pngmin/actions/workflows/ci.yml/badge.svg?branch=master\" alt=\"build status\"\u003e\u003c/a\u003e\n\n\u003e Grunt plugin to compress png images with pngquant.\n\n## Getting Started\n\nThis plugin requires Grunt `\u003e=1.0.0`\n\nIf you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install grunt-pngmin --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks(\"grunt-pngmin\");\n```\n\nWindows, Linux and Mac OSX is supported out of the box.\n\n## The \"pngmin\" task\n\n### Overview\n\nIn your project's Gruntfile, add a section named `pngmin` to the data object passed into `grunt.initConfig()`.\n\n```js\ngrunt.initConfig({\n  pngmin: {\n    options: {\n      // Task-specific options go here.\n    },\n    your_target: {\n      // Target-specific file lists and/or options go here.\n    },\n  },\n});\n```\n\n### Options\n\n#### options.concurrency\n\nType: `Number`\nDefault value: `4`\n\nHow many executables will be spawned in parallel.\n\n#### options.ext\n\nType: `String`\nDefault value: `'-fs8.png'`\n\nThe file extension after the quantization.\n\n#### options.quality\n\nType: `String`, `Object` or `Array`\nDefault value: `null`\n\nInstructs pngquant to use the least amount of colors required to meet or exceed the max quality.\nIf conversion results in quality below the min quality the image won't be saved.\nSpecify quality like that:\n\n- String: `'min-max'`\n- Object: `{min: min, max: max}`\n- Array: `[min, max]`\n\nmin and max are numbers in range 0 (worst) to 100 (perfect), similar to JPEG.\nFor example as object: `{min: 60, max: 80}`.\n\n#### options.force\n\nType: `Boolean`\nDefault value: `false`\n\nShould existing files be overwritten by the optimized version? Be careful with this option if you need the original files!\n\n#### options.speed\n\nType: `Number`\nDefault value: `3`\n\nSpeed/quality trade-off from 1 (brute-force) to 10 (fastest). Speed 10 has 5% lower quality, but is 8 times faster than the default.\n\n#### options.iebug\n\nType: `Boolean`\nDefault value: `false`\n\nWorkaround for IE6, which only displays fully opaque pixels. pngquant will make almost-opaque pixels fully opaque and will avoid creating new transparent colors.\n\n#### options.binary\n\nType: `String`\nDefault value: `'pngquant'` in your `PATH` or `'bin/pngquant'`\n\nThis option is just for users where the pngquant-bin package could not be installed correctly. Normally you don't need this!\nThe pngquant executable which will be spawned. If the pngquant binary is not found in `PATH` the default fallback is `'bin/pngquant'`, but this option has always precedence.\n\n#### options.retry\n\nType: `Boolean`\nDefault value: `true`\n\nIf pngquant exits with status 99 (ie it was not able to compress with the specified quality option), allow pngmin to try again without quality option.\n\n#### options.nofs\n\nType: `Boolean`\nDefault value: `false`\n\nIf `nofs` is set to `true` the Floyd-Steinberg dithering will be disabled.\n\n#### options.failOnError\n\nType: `Boolean`\nDefault value: `true`\n\nCauses the `grunt` command to also fail in case an error is encountered. For details, just add `--stack` to your `grunt` command.\n\n\n### Usage Examples\n\n#### Default Options\n\nIn this example `image.png` will be optimized, copied to `dest` folder and renamed to `image-fs8.png`.\n\n```js\ngrunt.initConfig({\n  pngmin: {\n    compile: {\n      options: {},\n      files: [\n        {\n          src: \"path/to/image.png\",\n          dest: \"dest/\",\n        },\n      ],\n    },\n  },\n});\n```\n\n#### Custom Options\n\nIn this example `image.png` will be optimized and copied to `dest` folder.\n\n```js\ngrunt.initConfig({\n  pngmin: {\n    compile: {\n      options: {\n        ext: \".png\",\n      },\n      files: [\n        {\n          src: \"path/to/image.png\",\n          dest: \"dest/\",\n        },\n      ],\n    },\n  },\n});\n```\n\nIn this example `image.png` gets overwritten by the optimized version, so use force option carefully!\n\n```js\ngrunt.initConfig({\n  pngmin: {\n    compile: {\n      options: {\n        ext: \".png\",\n        force: true,\n      },\n      files: [\n        {\n          src: \"path/to/image.png\",\n          dest: \"path/to/\",\n        },\n      ],\n    },\n  },\n});\n```\n\n#### Example which is preserving the subfolder structure\n\nIn this example all images in the folder `path/to/images/` and its subfolders will be optimized and copied to `dest` while preserving the directory structure.\nSee http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically for more options.\n\n```js\ngrunt.initConfig({\n  pngmin: {\n    compile: {\n      options: {\n        ext: \".png\",\n      },\n      files: [\n        {\n          expand: true, // required option\n          src: [\"**/*.png\"],\n          cwd: \"path/to/images/\", // required option\n          dest: \"dest/\",\n        },\n      ],\n    },\n  },\n});\n```\n\n#### Complex example\n\nThis is a complex example with a lot of options set:\n\n```js\ngrunt.initConfig({\n  pngmin: {\n    compile: {\n      options: {\n        concurrency: 8, // specify how many exucutables get spawned in parallel\n        ext: \".png\", // use .png as extension for the optimized files\n        quality: \"65-80\", // output quality should be between 65 and 80 like jpeg quality\n        speed: 10, // pngquant should be as fast as possible\n        iebug: true, // optimize image for use in Internet Explorer 6\n        nofs: true, // disable dithering\n      },\n      files: [\n        {\n          src: \"path/to/images/*.png\",\n          dest: \"dest/\",\n        },\n        {\n          src: \"path/to/other/images/*.png\",\n          dest: \"another/dest/\",\n        },\n      ],\n    },\n  },\n});\n```\n\n## Contributing\n\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.\n\nWhen writing unit tests, perform the following:\n\n1. Ensure you've got [`Node 20+`](https://nodejs.org/en/download/package-manager) setup and installed.\n1. Run install: `npm install`\n1. Run tests: `npm run test`\n\n## Release History\n\n- 2.0.3: Switch from chalk to yoctocolors for smaller install size (2024-06-30)\n- 2.0.2: Build system switch from Rollup to [tsup](https://tsup.egoist.dev/) (2024-06-24)\n- 2.0.0: Complete rewrite in TypeScript and update of all dependencies (to their latest CJS versions. ESM is not supported by Grunt) (2024-06-20)  \n  **BREAKING CHANGES:**  \n  - `failOnError` option is now `true` by default\n  - Requires Node.js 18+\n  - Requires Grunt.js 1.0+\n- 1.4.0: Reporting errors when failing to run `pngquant` and added option `failOnError`. To begin failing on errors, please set `failOnError` to `true`. (2020-07-10 via [#21](https://github.com/zauni/pngmin/issues/21))\n- 1.3.0: Option to disable Floyd-Steinberg dithering (2017-04-02)\n- 1.2.0: Option to specify if a retry is made when pngquant exits with status 99\n- 1.1.0: Updated all dependencies to the newest versions and removed colors and transbug options\n- 1.0.3: Compatibility with grunt 1.x\n- 1.0.2: Doesn't override images if savings were 0% (now for real, 1.0.1 was incorrect)\n- 1.0.1: Doesn't override images if savings were 0%\n- 1.0.0: Linux support with imagemin/pngquant-bin and travis CI integration\n- 0.6.4: Reverted some code from 0.6.3 and fixed one unit test\n- 0.6.3: Couple of fixes to prevent the reduce errors\n- 0.6.2: If pngquant exits with status 99, pngmin will try again without quality option (fixes [#9](https://github.com/zauni/pngmin/issues/9))\n- 0.6.1: Added postinstall script to change permission on the OS X pngquant binary\n- 0.6.0: pngquant binary is now included for windows and mac users (no additional pngquant installation need)\n- 0.5.1: Fixed potential issue with quality option\n- 0.5.0: Quality option of pngquant revealed to the plugin user\n- 0.4.5: Shows overall saved bytes\n- 0.4.4: Uses pngquant if it's in the `PATH`, otherwise uses fallback, but options.binary has always precedence\n- 0.4.3: Fixed issue with total percent\n- 0.4.2: Filesize of old and optimized image is shown\n- 0.4.1: Gives a hint if no images were found\n- 0.4.0: Destination doesn't have to be a directory anymore\n- 0.3.4: If the `force` option is false and the file already exists at the destination pngquant doesn't get spawned\n- 0.3.3: The total savings are displayed\n- 0.3.2: The force option is no longer required if '.png' is set as ext option\n- 0.3.1: If the optimization increases file size, the original file is copied to the destination\n- 0.3.0: Corrected behaviour if files object is built dynamically (http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically)\n- 0.2.1: Just one queue is created\n- 0.2.0: The pngquant executable gets queued to avoid a problem with too many spawned executables\n- 0.1.0: Initial release\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzauni%2Fpngmin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzauni%2Fpngmin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzauni%2Fpngmin/lists"}