diff --git a/README.md b/README.md index 2857bc59..471f5e2a 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ This project depends on - [ImageMagick](http://www.imagemagick.org/) >= 7 - [AdvPng](http://www.advancemame.it/doc-advpng.html) (optional) - [OptiPNG](http://optipng.sourceforge.net/) (optional) +- [pngquant](https://pngquant.org/) (optional) - [pnpm](https://pnpm.js.org) - [node.js](https://nodejs.org) >= 13 - [wine](https://www.winehq.org/) (optional) @@ -21,7 +22,7 @@ Windows binaries of these dependencies can be found on the download pages of the ### Linux ``` -$ sudo apt install nodejs imagemagick advancecomp optipng wine +$ sudo apt install nodejs imagemagick advancecomp optipng pngquant wine $ sudo npm install -g pnpm ``` @@ -54,7 +55,7 @@ Using [`brew`](https://brew.sh/) on a macOS: ``` $ brew cask install osxfuse wine-stable -$ brew install tup imagemagick advancecomp optipng +$ brew install tup imagemagick advancecomp optipng pngquant ``` ## Building @@ -71,6 +72,7 @@ Build settings are configurable in `tup.config`. - `CONFIG_DEFAULT_OPTIPNG`: Command line to pass to `optipng`. - `CONFIG_DEFAULT_ADVPNG`: Command line to pass to `advpng`. +- `CONFIG_DEFAULT_PNGQUANT`: Command line to pass to `pngquant`. - `CONFIG_DEFAULT_DEFLOPT`: `true`, `false`, or blank There are src-specific versions of these settings: diff --git a/Tuprules.lua b/Tuprules.lua index 903533ce..6b9a72dd 100644 --- a/Tuprules.lua +++ b/Tuprules.lua @@ -24,22 +24,23 @@ function trimimg(opts) -- Can't just be trim because of the string function... } end -local DEFAULT_OPTIPNG = getconfig("DEFAULT_OPTIPNG") -local DEFAULT_ADVPNG = getconfig("DEFAULT_ADVPNG") -local DEFAULT_DEFLOPT = booleanconfig("DEFAULT_DEFLOPT") - function compresspng(opts) local cmds = {} local output = opts.output or "%o" - local optipng = DEFAULT_OPTIPNG - local advpng = DEFAULT_ADVPNG - local deflopt = DEFAULT_DEFLOPT + local pngquant = getconfig("DEFAULT_PNGQUANT") + local optipng = getconfig("DEFAULT_OPTIPNG") + local advpng = getconfig("DEFAULT_ADVPNG") + local deflopt = booleanconfig("DEFAULT_DEFLOPT") if opts.config then + pngquant = getconfig(opts.config .. "_PNGQUANT") or pngquant; optipng = getconfig(opts.config .. "_OPTIPNG") or optipng; advpng = getconfig(opts.config .. "_ADVPNG") or advpng; deflopt = booleanconfig(opts.config .. "_DEFLOPT") or deflopt; end + if pngquant then + cmds += rep{"pngquant ${opts} ${output}", opts=pngquant, output=output} + end if optipng then cmds += rep{"optipng -q ${opts} ${output}", opts=optipng, output=output} end