Skip to content

Commit

Permalink
Merge pull request #140 from MrPropre/patch-1
Browse files Browse the repository at this point in the history
Add support for --skip-if-larger option of pngquant
  • Loading branch information
freekmurze committed Apr 22, 2021
2 parents 36363df + 01d57e9 commit db402f4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: |
sudo apt-get update -y
sudo apt-get install -y jpegoptim pngquant gifsicle optipng libjpeg-progs webp
sudo npm install -g svgo
sudo npm install -g svgo@1.3.2
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ before_script:
- sudo apt-get install optipng
- sudo apt-get install libjpeg-progs
- sudo apt-get install webp
- npm install -g svgo
- npm install -g svgo@1.3.2

script:
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The package will use these optimizers if they are present on your system:
- [JpegOptim](http://freecode.com/projects/jpegoptim)
- [Optipng](http://optipng.sourceforge.net/)
- [Pngquant 2](https://pngquant.org/)
- [SVGO](https://github.com/svg/svgo)
- [SVGO 1](https://github.com/svg/svgo)
- [Gifsicle](http://www.lcdf.org/gifsicle/)
- [cwebp](https://developers.google.com/speed/webp/docs/precompiled)

Expand All @@ -55,7 +55,7 @@ Here's how to install all the optimizers on Ubuntu:
sudo apt-get install jpegoptim
sudo apt-get install optipng
sudo apt-get install pngquant
sudo npm install -g svgo
sudo npm install -g svgo@1.3.2
sudo apt-get install gifsicle
sudo apt-get install webp
```
Expand All @@ -66,7 +66,7 @@ And here's how to install the binaries on MacOS (using [Homebrew](https://brew.s
brew install jpegoptim
brew install optipng
brew install pngquant
brew install svgo
brew install svgo@1.3.2
brew install gifsicle
brew install webp
```
Expand All @@ -77,7 +77,7 @@ sudo dnf install epel-release
sudo dnf install jpegoptim
sudo dnf install optipng
sudo dnf install pngquant
sudo npm install -g svgo
sudo npm install -g svgo@1.3.2
sudo dnf install gifsicle
sudo dnf install libwebp-tools
```
Expand All @@ -101,10 +101,12 @@ PNGs will be made smaller by running them through two tools. The first one is [P

### SVGs

SVGs will be minified by [SVGO](https://github.com/svg/svgo). SVGO's default configuration will be used, with the omission of the `cleanupIDs` plugin because that one is known to cause troubles when displaying multiple optimized SVGs on one page.
SVGs will be minified by [SVGO 1](https://github.com/svg/svgo). SVGO's default configuration will be used, with the omission of the `cleanupIDs` plugin because that one is known to cause troubles when displaying multiple optimized SVGs on one page.

Please be aware that SVGO can break your svg. You'll find more info on that in this [excellent blogpost](https://www.sarasoueidan.com/blog/svgo-tools/) by [Sara Soueidan](https://twitter.com/SaraSoueidan).

For now, the default configuration used for SVGO is only compatible with SVGO 1.x. To use options compatible with SVGO 2.x, you need to [create your own optimization chain](#creating-your-own-optimization-chains).

### GIFs

GIFs will be optimized by [Gifsicle](http://www.lcdf.org/gifsicle/). These options will be used:
Expand Down
1 change: 1 addition & 0 deletions src/OptimizerChainFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static function create(array $config = []): OptimizerChain
->addOptimizer(new Pngquant([
$pngQuality,
'--force',
'--skip-if-larger',
]))

->addOptimizer(new Optipng([
Expand Down

0 comments on commit db402f4

Please sign in to comment.