Cambio textos FAQS seccion registro
This commit is contained in:
@@ -1,55 +0,0 @@
|
||||
# Contributing
|
||||
|
||||
Contributions are **welcome** and will be fully **credited**.
|
||||
|
||||
Please read and understand the contribution guide before creating an issue or pull request.
|
||||
|
||||
## Etiquette
|
||||
|
||||
This project is open source, and as such, the maintainers give their free time to build and maintain the source code
|
||||
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
|
||||
extremely unfair for them to suffer abuse or anger for their hard work.
|
||||
|
||||
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
|
||||
world that developers are civilized and selfless people.
|
||||
|
||||
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
|
||||
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
|
||||
|
||||
## Viability
|
||||
|
||||
When requesting or submitting new features, first consider whether it might be useful to others. Open
|
||||
source projects are used by many developers, who may have entirely different needs to your own. Think about
|
||||
whether or not your feature is likely to be used by other users of the project.
|
||||
|
||||
## Procedure
|
||||
|
||||
Before filing an issue:
|
||||
|
||||
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
|
||||
- Check to make sure your feature suggestion isn't already present within the project.
|
||||
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
|
||||
- Check the pull requests tab to ensure that the feature isn't already in progress.
|
||||
|
||||
Before submitting a pull request:
|
||||
|
||||
- Check the codebase to ensure that your feature doesn't already exist.
|
||||
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
|
||||
|
||||
## Requirements
|
||||
|
||||
If the project maintainer has any additional requirements, you will find them listed here.
|
||||
|
||||
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
|
||||
|
||||
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
|
||||
|
||||
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
|
||||
|
||||
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
|
||||
|
||||
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
|
||||
|
||||
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
|
||||
|
||||
**Happy coding**!
|
||||
21
vendor/spatie/image-optimizer/.github/LICENSE.md
vendored
21
vendor/spatie/image-optimizer/.github/LICENSE.md
vendored
@@ -1,21 +0,0 @@
|
||||
# The MIT License (MIT)
|
||||
|
||||
Copyright (c) Spatie bvba <info@spatie.be>
|
||||
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in
|
||||
> all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
> THE SOFTWARE.
|
||||
@@ -1,23 +0,0 @@
|
||||
name: Check & fix styling
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
php-cs-fixer:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
|
||||
- name: Run PHP CS Fixer
|
||||
uses: docker://oskarstark/php-cs-fixer-ga
|
||||
with:
|
||||
args: --config=.php_cs.dist --allow-risky=yes
|
||||
|
||||
- name: Commit changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: Fix styling
|
||||
@@ -1,45 +0,0 @@
|
||||
name: Tests
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
php: [8.0, 7.4, 7.3, 7.2]
|
||||
dependency-version: [prefer-lowest, prefer-stable]
|
||||
|
||||
name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install optimizers
|
||||
run: |
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y jpegoptim pngquant gifsicle optipng libjpeg-progs webp
|
||||
sudo npm install -g svgo
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
|
||||
coverage: none
|
||||
|
||||
- name: Setup Problem Matches
|
||||
run: |
|
||||
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
|
||||
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
|
||||
|
||||
- name: Execute tests
|
||||
run: vendor/bin/phpunit
|
||||
|
||||
40
vendor/spatie/image-optimizer/.php_cs.dist
vendored
40
vendor/spatie/image-optimizer/.php_cs.dist
vendored
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
$finder = Symfony\Component\Finder\Finder::create()
|
||||
->in([
|
||||
__DIR__ . '/src',
|
||||
__DIR__ . '/tests',
|
||||
])
|
||||
->name('*.php')
|
||||
->notName('*.blade.php')
|
||||
->ignoreDotFiles(true)
|
||||
->ignoreVCS(true);
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRules([
|
||||
'@PSR2' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
|
||||
'no_unused_imports' => true,
|
||||
'not_operator_with_successor_space' => true,
|
||||
'trailing_comma_in_multiline_array' => true,
|
||||
'phpdoc_scalar' => true,
|
||||
'unary_operator_spaces' => true,
|
||||
'binary_operator_spaces' => true,
|
||||
'blank_line_before_statement' => [
|
||||
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
|
||||
],
|
||||
'phpdoc_single_line_var_spacing' => true,
|
||||
'phpdoc_var_without_name' => true,
|
||||
'class_attributes_separation' => [
|
||||
'elements' => [
|
||||
'method',
|
||||
],
|
||||
],
|
||||
'method_argument_space' => [
|
||||
'on_multiline' => 'ensure_fully_multiline',
|
||||
'keep_multiple_spaces_after_comma' => true,
|
||||
],
|
||||
'single_trait_insert_per_statement' => true,
|
||||
])
|
||||
->setFinder($finder);
|
||||
4
vendor/spatie/image-optimizer/.styleci.yml
vendored
4
vendor/spatie/image-optimizer/.styleci.yml
vendored
@@ -1,4 +0,0 @@
|
||||
preset: laravel
|
||||
|
||||
disabled:
|
||||
- single_class_element_per_statement
|
||||
107
vendor/spatie/image-optimizer/CHANGELOG.md
vendored
107
vendor/spatie/image-optimizer/CHANGELOG.md
vendored
@@ -1,107 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to `image-optimizer` will be documented in this file
|
||||
|
||||
## 1.3.2 - 2020-11-28
|
||||
|
||||
- improve gifsicle (#131)
|
||||
|
||||
## 1.3.1 - 2020-10-20
|
||||
|
||||
- fix empty string setBinaryPath() (#129)
|
||||
|
||||
## 1.3.0 - 2020-10-10
|
||||
|
||||
- add support for php 8.0
|
||||
|
||||
## 1.2.1 - 2019-11-23
|
||||
|
||||
- allow symfony 5 components
|
||||
|
||||
## 1.2.0 - 2019-08-28
|
||||
|
||||
- add support for webp
|
||||
|
||||
## 1.1.6 - 2019-08-26
|
||||
|
||||
- do not export docs directory
|
||||
|
||||
## 1.1.5 - 2019-01-15
|
||||
|
||||
- fix for svg's
|
||||
- make compatible with PHPUnit 8
|
||||
|
||||
## 1.1.4 - 2019-01-14
|
||||
|
||||
- fix deprecation warning for passing strings to processes
|
||||
|
||||
## 1.1.3 - 2018-11-19
|
||||
|
||||
- require the fileinfo extension
|
||||
|
||||
## 1.1.2 - 2018-10-10
|
||||
|
||||
- make sure all optimizers use `binaryPath`
|
||||
|
||||
## 1.1.1 - 2018-09-10
|
||||
|
||||
- fix logger output
|
||||
|
||||
## 1.1.0 - 2018-06-05
|
||||
|
||||
- add `setBinaryPath`
|
||||
|
||||
## 1.0.14 - 2018-03-07
|
||||
|
||||
- support more symfony versions
|
||||
|
||||
## 1.0.13 - 2018-02-26
|
||||
|
||||
- added `text/plain` to the list of valid svg mime types
|
||||
|
||||
## 1.0.12. - 2018-02-21
|
||||
|
||||
- added `image/svg+xml` mime type
|
||||
|
||||
## 1.0.11 - 2018-02-08
|
||||
|
||||
- SVG mime type detection in PHP 7.2
|
||||
|
||||
## 1.0.10 - 2018-02-08
|
||||
|
||||
- Support symfony ^4.0
|
||||
- Support phpunit ^7.0
|
||||
|
||||
## 1.0.9 - 2017-11-03
|
||||
- fix shell command quotes
|
||||
|
||||
## 1.0.8 - 2017-09-14
|
||||
- allow Symfony 2 components
|
||||
- make Google Pagespeed tests pass
|
||||
|
||||
## 1.0.7 - 2017-07-29
|
||||
- lower requirements of dependencies
|
||||
|
||||
## 1.0.6 - 2017-07-10
|
||||
- fix `jpegoptim` parameters
|
||||
|
||||
## 1.0.4 - 2017-07-07
|
||||
|
||||
- make `setTimeout` chainable
|
||||
|
||||
## 1.0.3 - 2017-07-06
|
||||
|
||||
- fix `composer.json`
|
||||
|
||||
## 1.0.2 - 2017-07-06
|
||||
|
||||
- fix for Laravel 5.5 users
|
||||
|
||||
## 1.0.1 - 2017-07-06
|
||||
|
||||
- improve security
|
||||
|
||||
|
||||
## 1.0.0 - 2017-07-05
|
||||
|
||||
- initial release
|
||||
365
vendor/spatie/image-optimizer/README.md
vendored
365
vendor/spatie/image-optimizer/README.md
vendored
@@ -1,365 +0,0 @@
|
||||
# Easily optimize images using PHP
|
||||
|
||||
[](https://packagist.org/packages/spatie/image-optimizer)
|
||||

|
||||
[](https://packagist.org/packages/spatie/image-optimizer)
|
||||
|
||||
This package can optimize PNGs, JPGs, SVGs and GIFs by running them through a chain of various [image optimization tools](#optimization-tools). Here's how you can use it:
|
||||
|
||||
```php
|
||||
use Spatie\ImageOptimizer\OptimizerChainFactory;
|
||||
|
||||
$optimizerChain = OptimizerChainFactory::create();
|
||||
|
||||
$optimizerChain->optimize($pathToImage);
|
||||
```
|
||||
|
||||
The image at `$pathToImage` will be overwritten by an optimized version which should be smaller. The package will automatically detect which optimization binaries are installed on your system and use them.
|
||||
|
||||
Here are some [example conversions](#example-conversions) that have been done by this package.
|
||||
|
||||
Loving Laravel? Then head over to [the Laravel specific integration](https://github.com/spatie/laravel-image-optimizer).
|
||||
|
||||
Using WordPress? Then try out [the WP CLI command](https://github.com/TypistTech/image-optimize-command).
|
||||
|
||||
## Support us
|
||||
|
||||
[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/image-optimizer.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/image-optimizer)
|
||||
|
||||
We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
|
||||
|
||||
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
|
||||
|
||||
## Installation
|
||||
|
||||
You can install the package via composer:
|
||||
|
||||
```bash
|
||||
composer require spatie/image-optimizer
|
||||
```
|
||||
|
||||
### Optimization tools
|
||||
|
||||
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)
|
||||
- [Gifsicle](http://www.lcdf.org/gifsicle/)
|
||||
- [cwebp](https://developers.google.com/speed/webp/docs/precompiled)
|
||||
|
||||
Here's how to install all the optimizers on Ubuntu:
|
||||
|
||||
```bash
|
||||
sudo apt-get install jpegoptim
|
||||
sudo apt-get install optipng
|
||||
sudo apt-get install pngquant
|
||||
sudo npm install -g svgo
|
||||
sudo apt-get install gifsicle
|
||||
sudo apt-get install webp
|
||||
```
|
||||
|
||||
And here's how to install the binaries on MacOS (using [Homebrew](https://brew.sh/)):
|
||||
|
||||
```bash
|
||||
brew install jpegoptim
|
||||
brew install optipng
|
||||
brew install pngquant
|
||||
brew install svgo
|
||||
brew install gifsicle
|
||||
brew install webp
|
||||
```
|
||||
And here's how to install the binaries on Fedora/RHEL/CentOS:
|
||||
|
||||
```bash
|
||||
sudo dnf install epel-release
|
||||
sudo dnf install jpegoptim
|
||||
sudo dnf install optipng
|
||||
sudo dnf install pngquant
|
||||
sudo npm install -g svgo
|
||||
sudo dnf install gifsicle
|
||||
sudo dnf install libwebp-tools
|
||||
```
|
||||
|
||||
## Which tools will do what?
|
||||
|
||||
The package will automatically decide which tools to use on a particular image.
|
||||
|
||||
### JPGs
|
||||
|
||||
JPGs will be made smaller by running them through [JpegOptim](http://freecode.com/projects/jpegoptim). These options are used:
|
||||
- `-m85`: this will store the image with 85% quality. This setting [seems to satisfy Google's Pagespeed compression rules](https://webmasters.stackexchange.com/questions/102094/google-pagespeed-how-to-satisfy-the-new-image-compression-rules)
|
||||
- `--strip-all`: this strips out all text information such as comments and EXIF data
|
||||
- `--all-progressive`: this will make sure the resulting image is a progressive one, meaning it can be downloaded using multiple passes of progressively higher details.
|
||||
|
||||
### PNGs
|
||||
|
||||
PNGs will be made smaller by running them through two tools. The first one is [Pngquant 2](https://pngquant.org/), a lossy PNG compressor. We set no extra options, their defaults are used. After that we run the image through a second one: [Optipng](http://optipng.sourceforge.net/). These options are used:
|
||||
- `-i0`: this will result in a non-interlaced, progressive scanned image
|
||||
- `-o2`: this set the optimization level to two (multiple IDAT compression trials)
|
||||
|
||||
This package only supports Pngquant 2.5 and lower.
|
||||
|
||||
### 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.
|
||||
|
||||
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).
|
||||
|
||||
### GIFs
|
||||
|
||||
GIFs will be optimized by [Gifsicle](http://www.lcdf.org/gifsicle/). These options will be used:
|
||||
- `-O3`: this sets the optimization level to Gifsicle's maximum, which produces the slowest but best results
|
||||
|
||||
### WEBPs
|
||||
|
||||
WEBPs will be optimized by [Cwebp](https://developers.google.com/speed/webp/docs/cwebp). These options will be used:
|
||||
- `-m 6` for the slowest compression method in order to get the best compression.
|
||||
- `-pass 10` for maximizing the amount of analysis pass.
|
||||
- `-mt` multithreading for some speed improvements.
|
||||
- `-q 90` Quality factor that brings the least noticeable changes.
|
||||
|
||||
(Settings are original taken from [here](https://medium.com/@vinhlh/how-i-apply-webp-for-optimizing-images-9b11068db349))
|
||||
|
||||
## Usage
|
||||
|
||||
This is the default way to use the package:
|
||||
|
||||
``` php
|
||||
use Spatie\ImageOptimizer\OptimizerChainFactory;
|
||||
|
||||
$optimizerChain = OptimizerChainFactory::create();
|
||||
|
||||
$optimizerChain->optimize($pathToImage);
|
||||
```
|
||||
|
||||
The image at `$pathToImage` will be overwritten by an optimized version which should be smaller.
|
||||
|
||||
The package will automatically detect which optimization binaries are installed on your system and use them.
|
||||
|
||||
To keep the original image, you can pass through a second argument`optimize`:
|
||||
```php
|
||||
use Spatie\ImageOptimizer\OptimizerChainFactory;
|
||||
|
||||
$optimizerChain = OptimizerChainFactory::create();
|
||||
|
||||
$optimizerChain->optimize($pathToImage, $pathToOutput);
|
||||
```
|
||||
|
||||
In that example the package won't touch `$pathToImage` and write an optimized version to `$pathToOutput`.
|
||||
|
||||
### Setting a timeout
|
||||
|
||||
You can set the maximum of time in seconds that each individual optimizer in a chain can use by calling `setTimeout`:
|
||||
|
||||
```php
|
||||
$optimizerChain
|
||||
->setTimeout(10)
|
||||
->optimize($pathToImage);
|
||||
```
|
||||
|
||||
In this example each optimizer in the chain will get a maximum 10 seconds to do it's job.
|
||||
|
||||
### Creating your own optimization chains
|
||||
|
||||
If you want to customize the chain of optimizers you can do so by adding `Optimizer`s manually to an `OptimizerChain`.
|
||||
|
||||
Here's an example where we only want `optipng` and `jpegoptim` to be used:
|
||||
|
||||
```php
|
||||
use Spatie\ImageOptimizer\OptimizerChain;
|
||||
use Spatie\ImageOptimizer\Optimizers\Jpegoptim;
|
||||
use Spatie\ImageOptimizer\Optimizers\Pngquant;
|
||||
|
||||
$optimizerChain = (new OptimizerChain)
|
||||
->addOptimizer(new Jpegoptim([
|
||||
'--strip-all',
|
||||
'--all-progressive',
|
||||
]))
|
||||
|
||||
->addOptimizer(new Pngquant([
|
||||
'--force',
|
||||
]))
|
||||
```
|
||||
|
||||
Notice that you can pass the options an `Optimizer` should use to its constructor.
|
||||
|
||||
### Writing a custom optimizers
|
||||
|
||||
Want to use another command line utility to optimize your images? No problem. Just write your own optimizer. An optimizer is any class that implements the `Spatie\ImageOptimizer\Optimizers\Optimizer` interface:
|
||||
|
||||
```php
|
||||
namespace Spatie\ImageOptimizer\Optimizers;
|
||||
|
||||
use Spatie\ImageOptimizer\Image;
|
||||
|
||||
interface Optimizer
|
||||
{
|
||||
/**
|
||||
* Returns the name of the binary to be executed.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function binaryName(): string;
|
||||
|
||||
/**
|
||||
* Determines if the given image can be handled by the optimizer.
|
||||
*
|
||||
* @param \Spatie\ImageOptimizer\Image $image
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canHandle(Image $image): bool;
|
||||
|
||||
/**
|
||||
* Set the path to the image that should be optimized.
|
||||
*
|
||||
* @param string $imagePath
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setImagePath(string $imagePath);
|
||||
|
||||
/**
|
||||
* Set the options the optimizer should use.
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setOptions(array $options = []);
|
||||
|
||||
/**
|
||||
* Get the command that should be executed.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCommand(): string;
|
||||
}
|
||||
```
|
||||
|
||||
If you want to view an example implementation take a look at [the existing optimizers](https://github.com/spatie/image-optimizer/tree/master/src/Optimizers) shipped with this package.
|
||||
|
||||
You can easily add your optimizer by using the `addOptimizer` method on an `OptimizerChain`.
|
||||
|
||||
``` php
|
||||
use Spatie\ImageOptimizer\ImageOptimizerFactory;
|
||||
|
||||
$optimizerChain = OptimizerChainFactory::create();
|
||||
|
||||
$optimizerChain
|
||||
->addOptimizer(new YourCustomOptimizer())
|
||||
->optimize($pathToImage);
|
||||
```
|
||||
|
||||
## Logging the optimization process
|
||||
|
||||
By default the package will not throw any errors and just operate silently. To verify what the package is doing you can set a logger:
|
||||
|
||||
```php
|
||||
use Spatie\ImageOptimizer\OptimizerChainFactory;
|
||||
|
||||
$optimizerChain = OptimizerChainFactory::create();
|
||||
|
||||
$optimizerChain
|
||||
->useLogger(new MyLogger())
|
||||
->optimize($pathToImage);
|
||||
```
|
||||
|
||||
A logger is a class that implements `Psr\Log\LoggerInterface`. A good logging library that's fully compliant is [Monolog](https://github.com/Seldaek/monolog). The package will write to log which `Optimizers` are used, which commands are executed and their output.
|
||||
|
||||
## Example conversions
|
||||
|
||||
Here are some real life example conversions done by this package.
|
||||
|
||||
### png
|
||||
|
||||
Original: Photoshop 'Save for web' | PNG-24 with transparency<br>
|
||||
40 KB
|
||||
|
||||

|
||||
|
||||
Optimized<br>
|
||||
16 KB (40%)
|
||||
|
||||

|
||||
|
||||
### jpg
|
||||
|
||||
Original: Photoshop 'Save for web' | quality 60, optimized<br>
|
||||
547 KB
|
||||
|
||||

|
||||
|
||||
Optimized<br>
|
||||
525 KB (95%)
|
||||
|
||||

|
||||
|
||||
credits: Jeff Sheldon, via [Unsplash](https://unsplash.com)
|
||||
|
||||
### svg
|
||||
|
||||
Original: Illustrator | Web optimized SVG export<br>
|
||||
26 KB
|
||||
|
||||

|
||||
|
||||
Optimized<br>
|
||||
20 KB (76%)
|
||||
|
||||

|
||||
|
||||
### webp
|
||||
|
||||
Original: WebPonize<br>
|
||||
528 KB
|
||||
|
||||

|
||||
|
||||
Optimized<br>
|
||||
328 KB (89%)
|
||||
|
||||

|
||||
|
||||
credits: Jeff Sheldon, via [Unsplash](https://unsplash.com)
|
||||
|
||||
## Changelog
|
||||
|
||||
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
|
||||
|
||||
## Testing
|
||||
|
||||
``` bash
|
||||
composer test
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
|
||||
|
||||
## Security
|
||||
|
||||
If you discover any security related issues, please email freek@spatie.be instead of using the issue tracker.
|
||||
|
||||
## Postcardware
|
||||
|
||||
You're free to use this package (it's [MIT-licensed](.github/LICENSE.md)), but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.
|
||||
|
||||
Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.
|
||||
|
||||
We publish all received postcards [on our company website](https://spatie.be/en/opensource/postcards).
|
||||
|
||||
## Credits
|
||||
|
||||
- [Freek Van der Herten](https://github.com/freekmurze)
|
||||
- [All Contributors](../../contributors)
|
||||
|
||||
This package has been inspired by [psliwa/image-optimizer](https://github.com/psliwa/image-optimizer)
|
||||
|
||||
Emotional support provided by [Joke Forment](https://twitter.com/pronneur)
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT). Please see [License File](.github/LICENSE.md) for more information.
|
||||
47
vendor/spatie/image-optimizer/composer.json
vendored
47
vendor/spatie/image-optimizer/composer.json
vendored
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"name": "spatie/image-optimizer",
|
||||
"description": "Easily optimize images using PHP",
|
||||
"keywords": [
|
||||
"spatie",
|
||||
"image-optimizer"
|
||||
],
|
||||
"homepage": "https://github.com/spatie/image-optimizer",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Freek Van der Herten",
|
||||
"email": "freek@spatie.be",
|
||||
"homepage": "https://spatie.be",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2|^8.0",
|
||||
"ext-fileinfo": "*",
|
||||
"psr/log": "^1.0",
|
||||
"symfony/process": "^4.2|^5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^8.0|^9.0",
|
||||
"symfony/var-dumper": "^4.2|^5.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Spatie\\ImageOptimizer\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Spatie\\ImageOptimizer\\Test\\": "tests"
|
||||
},
|
||||
"files": [
|
||||
"tests/helpers.php"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vendor/bin/phpunit"
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\ImageOptimizer;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class DummyLogger implements LoggerInterface
|
||||
{
|
||||
public function emergency($message, array $context = [])
|
||||
{
|
||||
}
|
||||
|
||||
public function alert($message, array $context = [])
|
||||
{
|
||||
}
|
||||
|
||||
public function critical($message, array $context = [])
|
||||
{
|
||||
}
|
||||
|
||||
public function error($message, array $context = [])
|
||||
{
|
||||
}
|
||||
|
||||
public function warning($message, array $context = [])
|
||||
{
|
||||
}
|
||||
|
||||
public function notice($message, array $context = [])
|
||||
{
|
||||
}
|
||||
|
||||
public function info($message, array $context = [])
|
||||
{
|
||||
}
|
||||
|
||||
public function debug($message, array $context = [])
|
||||
{
|
||||
}
|
||||
|
||||
public function log($level, $message, array $context = [])
|
||||
{
|
||||
}
|
||||
}
|
||||
36
vendor/spatie/image-optimizer/src/Image.php
vendored
36
vendor/spatie/image-optimizer/src/Image.php
vendored
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\ImageOptimizer;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
class Image
|
||||
{
|
||||
protected $pathToImage = '';
|
||||
|
||||
public function __construct(string $pathToImage)
|
||||
{
|
||||
if (! file_exists($pathToImage)) {
|
||||
throw new InvalidArgumentException("`{$pathToImage}` does not exist");
|
||||
}
|
||||
|
||||
$this->pathToImage = $pathToImage;
|
||||
}
|
||||
|
||||
public function mime(): string
|
||||
{
|
||||
return mime_content_type($this->pathToImage);
|
||||
}
|
||||
|
||||
public function path(): string
|
||||
{
|
||||
return $this->pathToImage;
|
||||
}
|
||||
|
||||
public function extension(): string
|
||||
{
|
||||
$extension = pathinfo($this->pathToImage, PATHINFO_EXTENSION);
|
||||
|
||||
return strtolower($extension);
|
||||
}
|
||||
}
|
||||
47
vendor/spatie/image-optimizer/src/Optimizer.php
vendored
47
vendor/spatie/image-optimizer/src/Optimizer.php
vendored
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\ImageOptimizer;
|
||||
|
||||
interface Optimizer
|
||||
{
|
||||
/**
|
||||
* Returns the name of the binary to be executed.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function binaryName(): string;
|
||||
|
||||
/**
|
||||
* Determines if the given image can be handled by the optimizer.
|
||||
*
|
||||
* @param \Spatie\ImageOptimizer\Image $image
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canHandle(Image $image): bool;
|
||||
|
||||
/**
|
||||
* Set the path to the image that should be optimized.
|
||||
*
|
||||
* @param string $imagePath
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setImagePath(string $imagePath);
|
||||
|
||||
/**
|
||||
* Set the options the optimizer should use.
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setOptions(array $options = []);
|
||||
|
||||
/**
|
||||
* Get the command that should be executed.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCommand(): string;
|
||||
}
|
||||
116
vendor/spatie/image-optimizer/src/OptimizerChain.php
vendored
116
vendor/spatie/image-optimizer/src/OptimizerChain.php
vendored
@@ -1,116 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\ImageOptimizer;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class OptimizerChain
|
||||
{
|
||||
/* @var \Spatie\ImageOptimizer\Optimizer[] */
|
||||
protected $optimizers = [];
|
||||
|
||||
/** @var \Psr\Log\LoggerInterface */
|
||||
protected $logger;
|
||||
|
||||
/** @var int */
|
||||
protected $timeout = 60;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->useLogger(new DummyLogger());
|
||||
}
|
||||
|
||||
public function getOptimizers(): array
|
||||
{
|
||||
return $this->optimizers;
|
||||
}
|
||||
|
||||
public function addOptimizer(Optimizer $optimizer)
|
||||
{
|
||||
$this->optimizers[] = $optimizer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setOptimizers(array $optimizers)
|
||||
{
|
||||
$this->optimizers = [];
|
||||
|
||||
foreach ($optimizers as $optimizer) {
|
||||
$this->addOptimizer($optimizer);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the amount of seconds each separate optimizer may use.
|
||||
*/
|
||||
public function setTimeout(int $timeoutInSeconds)
|
||||
{
|
||||
$this->timeout = $timeoutInSeconds;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function useLogger(LoggerInterface $log)
|
||||
{
|
||||
$this->logger = $log;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function optimize(string $pathToImage, string $pathToOutput = null)
|
||||
{
|
||||
if ($pathToOutput) {
|
||||
copy($pathToImage, $pathToOutput);
|
||||
|
||||
$pathToImage = $pathToOutput;
|
||||
}
|
||||
|
||||
$image = new Image($pathToImage);
|
||||
|
||||
$this->logger->info("Start optimizing {$pathToImage}");
|
||||
|
||||
foreach ($this->optimizers as $optimizer) {
|
||||
$this->applyOptimizer($optimizer, $image);
|
||||
}
|
||||
}
|
||||
|
||||
protected function applyOptimizer(Optimizer $optimizer, Image $image)
|
||||
{
|
||||
if (! $optimizer->canHandle($image)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$optimizerClass = get_class($optimizer);
|
||||
|
||||
$this->logger->info("Using optimizer: `{$optimizerClass}`");
|
||||
|
||||
$optimizer->setImagePath($image->path());
|
||||
|
||||
$command = $optimizer->getCommand();
|
||||
|
||||
$this->logger->info("Executing `{$command}`");
|
||||
|
||||
$process = Process::fromShellCommandline($command);
|
||||
|
||||
$process
|
||||
->setTimeout($this->timeout)
|
||||
->run();
|
||||
|
||||
$this->logResult($process);
|
||||
}
|
||||
|
||||
protected function logResult(Process $process)
|
||||
{
|
||||
if (! $process->isSuccessful()) {
|
||||
$this->logger->error("Process errored with `{$process->getErrorOutput()}`");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->logger->info("Process successfully ended with output `{$process->getOutput()}`");
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\ImageOptimizer;
|
||||
|
||||
use Spatie\ImageOptimizer\Optimizers\Cwebp;
|
||||
use Spatie\ImageOptimizer\Optimizers\Gifsicle;
|
||||
use Spatie\ImageOptimizer\Optimizers\Jpegoptim;
|
||||
use Spatie\ImageOptimizer\Optimizers\Optipng;
|
||||
use Spatie\ImageOptimizer\Optimizers\Pngquant;
|
||||
use Spatie\ImageOptimizer\Optimizers\Svgo;
|
||||
|
||||
class OptimizerChainFactory
|
||||
{
|
||||
public static function create(array $config = []): OptimizerChain
|
||||
{
|
||||
$jpegQuality = '--max=85';
|
||||
$pngQuality = '--quality=85';
|
||||
if (isset($config['quality'])) {
|
||||
$jpegQuality = '--max='.$config['quality'];
|
||||
$pngQuality = '--quality='.$config['quality'];
|
||||
}
|
||||
|
||||
return (new OptimizerChain())
|
||||
->addOptimizer(new Jpegoptim([
|
||||
$jpegQuality,
|
||||
'--strip-all',
|
||||
'--all-progressive',
|
||||
]))
|
||||
|
||||
->addOptimizer(new Pngquant([
|
||||
$pngQuality,
|
||||
'--force',
|
||||
]))
|
||||
|
||||
->addOptimizer(new Optipng([
|
||||
'-i0',
|
||||
'-o2',
|
||||
'-quiet',
|
||||
]))
|
||||
|
||||
->addOptimizer(new Svgo([
|
||||
'--disable={cleanupIDs,removeViewBox}',
|
||||
]))
|
||||
|
||||
->addOptimizer(new Gifsicle([
|
||||
'-b',
|
||||
'-O3',
|
||||
]))
|
||||
->addOptimizer(new Cwebp([
|
||||
'-m 6',
|
||||
'-pass 10',
|
||||
'-mt',
|
||||
'-q 80',
|
||||
]));
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\ImageOptimizer\Optimizers;
|
||||
|
||||
use Spatie\ImageOptimizer\Optimizer;
|
||||
|
||||
abstract class BaseOptimizer implements Optimizer
|
||||
{
|
||||
public $options = [];
|
||||
|
||||
public $imagePath = '';
|
||||
|
||||
public $binaryPath = '';
|
||||
|
||||
public function __construct($options = [])
|
||||
{
|
||||
$this->setOptions($options);
|
||||
}
|
||||
|
||||
public function binaryName(): string
|
||||
{
|
||||
return $this->binaryName;
|
||||
}
|
||||
|
||||
public function setBinaryPath(string $binaryPath)
|
||||
{
|
||||
if (strlen($binaryPath) > 0 && substr($binaryPath, -1) !== DIRECTORY_SEPARATOR) {
|
||||
$binaryPath = $binaryPath.DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
$this->binaryPath = $binaryPath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setImagePath(string $imagePath)
|
||||
{
|
||||
$this->imagePath = $imagePath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setOptions(array $options = [])
|
||||
{
|
||||
$this->options = $options;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCommand(): string
|
||||
{
|
||||
$optionString = implode(' ', $this->options);
|
||||
|
||||
return "\"{$this->binaryPath}{$this->binaryName}\" {$optionString} ".escapeshellarg($this->imagePath);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\ImageOptimizer\Optimizers;
|
||||
|
||||
use Spatie\ImageOptimizer\Image;
|
||||
|
||||
class Cwebp extends BaseOptimizer
|
||||
{
|
||||
public $binaryName = 'cwebp';
|
||||
|
||||
public function canHandle(Image $image): bool
|
||||
{
|
||||
return $image->mime() === 'image/webp';
|
||||
}
|
||||
|
||||
public function getCommand(): string
|
||||
{
|
||||
$optionString = implode(' ', $this->options);
|
||||
|
||||
return "\"{$this->binaryPath}{$this->binaryName}\" {$optionString}"
|
||||
.' '.escapeshellarg($this->imagePath)
|
||||
.' -o '.escapeshellarg($this->imagePath);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\ImageOptimizer\Optimizers;
|
||||
|
||||
use Spatie\ImageOptimizer\Image;
|
||||
|
||||
class Gifsicle extends BaseOptimizer
|
||||
{
|
||||
public $binaryName = 'gifsicle';
|
||||
|
||||
public function canHandle(Image $image): bool
|
||||
{
|
||||
return $image->mime() === 'image/gif';
|
||||
}
|
||||
|
||||
public function getCommand(): string
|
||||
{
|
||||
$optionString = implode(' ', $this->options);
|
||||
|
||||
return "\"{$this->binaryPath}{$this->binaryName}\" {$optionString}"
|
||||
.' -i '.escapeshellarg($this->imagePath)
|
||||
.' -o '.escapeshellarg($this->imagePath);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\ImageOptimizer\Optimizers;
|
||||
|
||||
use Spatie\ImageOptimizer\Image;
|
||||
|
||||
class Jpegoptim extends BaseOptimizer
|
||||
{
|
||||
public $binaryName = 'jpegoptim';
|
||||
|
||||
public function canHandle(Image $image): bool
|
||||
{
|
||||
return $image->mime() === 'image/jpeg';
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\ImageOptimizer\Optimizers;
|
||||
|
||||
use Spatie\ImageOptimizer\Image;
|
||||
|
||||
class Optipng extends BaseOptimizer
|
||||
{
|
||||
public $binaryName = 'optipng';
|
||||
|
||||
public function canHandle(Image $image): bool
|
||||
{
|
||||
return $image->mime() === 'image/png';
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\ImageOptimizer\Optimizers;
|
||||
|
||||
use Spatie\ImageOptimizer\Image;
|
||||
|
||||
class Pngquant extends BaseOptimizer
|
||||
{
|
||||
public $binaryName = 'pngquant';
|
||||
|
||||
public function canHandle(Image $image): bool
|
||||
{
|
||||
return $image->mime() === 'image/png';
|
||||
}
|
||||
|
||||
public function getCommand(): string
|
||||
{
|
||||
$optionString = implode(' ', $this->options);
|
||||
|
||||
return "\"{$this->binaryPath}{$this->binaryName}\" {$optionString}"
|
||||
.' '.escapeshellarg($this->imagePath)
|
||||
.' --output='.escapeshellarg($this->imagePath);
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\ImageOptimizer\Optimizers;
|
||||
|
||||
use Spatie\ImageOptimizer\Image;
|
||||
|
||||
class Svgo extends BaseOptimizer
|
||||
{
|
||||
public $binaryName = 'svgo';
|
||||
|
||||
public function canHandle(Image $image): bool
|
||||
{
|
||||
if ($image->extension() !== 'svg') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return in_array($image->mime(), [
|
||||
'text/html',
|
||||
'image/svg',
|
||||
'image/svg+xml',
|
||||
'text/plain',
|
||||
]);
|
||||
}
|
||||
|
||||
public function getCommand(): string
|
||||
{
|
||||
$optionString = implode(' ', $this->options);
|
||||
|
||||
return "\"{$this->binaryPath}{$this->binaryName}\" {$optionString}"
|
||||
.' --input='.escapeshellarg($this->imagePath)
|
||||
.' --output='.escapeshellarg($this->imagePath);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
# Contributing
|
||||
|
||||
Contributions are **welcome** and will be fully **credited**.
|
||||
|
||||
Please read and understand the contribution guide before creating an issue or pull request.
|
||||
|
||||
## Etiquette
|
||||
|
||||
This project is open source, and as such, the maintainers give their free time to build and maintain the source code
|
||||
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
|
||||
extremely unfair for them to suffer abuse or anger for their hard work.
|
||||
|
||||
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
|
||||
world that developers are civilized and selfless people.
|
||||
|
||||
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
|
||||
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
|
||||
|
||||
## Viability
|
||||
|
||||
When requesting or submitting new features, first consider whether it might be useful to others. Open
|
||||
source projects are used by many developers, who may have entirely different needs to your own. Think about
|
||||
whether or not your feature is likely to be used by other users of the project.
|
||||
|
||||
## Procedure
|
||||
|
||||
Before filing an issue:
|
||||
|
||||
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
|
||||
- Check to make sure your feature suggestion isn't already present within the project.
|
||||
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
|
||||
- Check the pull requests tab to ensure that the feature isn't already in progress.
|
||||
|
||||
Before submitting a pull request:
|
||||
|
||||
- Check the codebase to ensure that your feature doesn't already exist.
|
||||
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
|
||||
|
||||
## Requirements
|
||||
|
||||
If the project maintainer has any additional requirements, you will find them listed here.
|
||||
|
||||
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
|
||||
|
||||
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
|
||||
|
||||
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
|
||||
|
||||
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
|
||||
|
||||
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
|
||||
|
||||
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
|
||||
|
||||
**Happy coding**!
|
||||
@@ -1 +0,0 @@
|
||||
custom: https://spatie.be/open-source/support-us
|
||||
@@ -1,23 +0,0 @@
|
||||
name: Check & fix styling
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
php-cs-fixer:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
|
||||
- name: Run PHP CS Fixer
|
||||
uses: docker://oskarstark/php-cs-fixer-ga
|
||||
with:
|
||||
args: --config=.php_cs.dist --allow-risky=yes
|
||||
|
||||
- name: Commit changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: Fix styling
|
||||
@@ -1,57 +0,0 @@
|
||||
name: Tests
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
php: [8.0, 7.4, 7.3]
|
||||
laravel: [8.*, 7.*]
|
||||
dependency-version: [prefer-lowest, prefer-stable]
|
||||
include:
|
||||
- laravel: 8.*
|
||||
testbench: 6.*
|
||||
- laravel: 7.*
|
||||
testbench: 5.*
|
||||
|
||||
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 10
|
||||
- name: Install tools
|
||||
run: sudo apt-get install jpegoptim
|
||||
&& sudo apt-get install pngquant
|
||||
&& sudo apt-get install gifsicle
|
||||
&& sudo apt-get install optipng
|
||||
&& sudo apt-get install libjpeg-progs
|
||||
&& npm install -g svgo
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.composer/cache/files
|
||||
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
|
||||
coverage: none
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
|
||||
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
|
||||
|
||||
- name: Execute tests
|
||||
run: vendor/bin/phpunit
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
$finder = Symfony\Component\Finder\Finder::create()
|
||||
->notPath('bootstrap/*')
|
||||
->notPath('storage/*')
|
||||
->notPath('resources/view/mail/*')
|
||||
->in([
|
||||
__DIR__ . '/src',
|
||||
__DIR__ . '/tests',
|
||||
])
|
||||
->name('*.php')
|
||||
->notName('*.blade.php')
|
||||
->ignoreDotFiles(true)
|
||||
->ignoreVCS(true);
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRules([
|
||||
'@PSR2' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
|
||||
'no_unused_imports' => true,
|
||||
'not_operator_with_successor_space' => true,
|
||||
'trailing_comma_in_multiline_array' => true,
|
||||
'phpdoc_scalar' => true,
|
||||
'unary_operator_spaces' => true,
|
||||
'binary_operator_spaces' => true,
|
||||
'blank_line_before_statement' => [
|
||||
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
|
||||
],
|
||||
'phpdoc_single_line_var_spacing' => true,
|
||||
'phpdoc_var_without_name' => true,
|
||||
'method_argument_space' => [
|
||||
'on_multiline' => 'ensure_fully_multiline',
|
||||
'keep_multiple_spaces_after_comma' => true,
|
||||
]
|
||||
])
|
||||
->setFinder($finder);
|
||||
@@ -1,72 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to `laravel-image-optimizer` will be documented in this file
|
||||
|
||||
## 1.6.4 - 2020-11-27
|
||||
|
||||
- add support for PHP 8
|
||||
|
||||
## 1.6.3 - 2020-09-08
|
||||
|
||||
- add support for Laravel 8
|
||||
|
||||
## 1.6.2 - 2020-07-14
|
||||
|
||||
- bugfix for custom logger (#87)
|
||||
|
||||
## 1.6.1 - 2020-03-10
|
||||
|
||||
- fix deps
|
||||
|
||||
## 1.6.0 - 2020-03-02
|
||||
|
||||
- add support for L7
|
||||
|
||||
## 1.5.1 - 2019-11-02
|
||||
|
||||
- only optimize files that were uploaded without errors (#75)
|
||||
|
||||
## 1.5.0 - 2019-09-04
|
||||
|
||||
- make compatible with Laravel 6
|
||||
|
||||
## 1.4.0 - 2019-02-27
|
||||
|
||||
- drop support for PHP 7.1
|
||||
|
||||
## 1.3.3 - 2019-02-27
|
||||
|
||||
- drop support for PHP 7.0
|
||||
- add support for Laravel 5.8
|
||||
|
||||
## 1.3.2 - 2018-08-27
|
||||
- add support for Laravel 5.7
|
||||
|
||||
## 1.3.1 - 2018-06-05
|
||||
- make sure a compatible version of spatie/image-optimizer is being pulled in
|
||||
|
||||
## 1.3.0 - 2018-06-05
|
||||
- add compatibility with Lumen
|
||||
|
||||
## 1.2.0 - 2018-05-16
|
||||
- add `binary_path` to config file
|
||||
|
||||
## 1.1.3 - 2018-02-08
|
||||
- add support for L5.6
|
||||
- drop support for L5.4
|
||||
|
||||
## 1.1.2 - 2017-12-11
|
||||
- fix issue with middleware and images in multidimensional input arrays
|
||||
- fix issue where jpegs would not be optimized correctly
|
||||
|
||||
## 1.1.1
|
||||
- fix for multipe file uploads
|
||||
|
||||
## 1.1.0
|
||||
- add support for Laravel 5.5
|
||||
|
||||
## 1.0.1 - 2017-07-22
|
||||
- fix initial package autodiscovery support
|
||||
|
||||
## 1.0.0 - 2017-07-13
|
||||
- initial release
|
||||
@@ -1,55 +0,0 @@
|
||||
# Contributing
|
||||
|
||||
Contributions are **welcome** and will be fully **credited**.
|
||||
|
||||
Please read and understand the contribution guide before creating an issue or pull request.
|
||||
|
||||
## Etiquette
|
||||
|
||||
This project is open source, and as such, the maintainers give their free time to build and maintain the source code
|
||||
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
|
||||
extremely unfair for them to suffer abuse or anger for their hard work.
|
||||
|
||||
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
|
||||
world that developers are civilized and selfless people.
|
||||
|
||||
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
|
||||
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
|
||||
|
||||
## Viability
|
||||
|
||||
When requesting or submitting new features, first consider whether it might be useful to others. Open
|
||||
source projects are used by many developers, who may have entirely different needs to your own. Think about
|
||||
whether or not your feature is likely to be used by other users of the project.
|
||||
|
||||
## Procedure
|
||||
|
||||
Before filing an issue:
|
||||
|
||||
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
|
||||
- Check to make sure your feature suggestion isn't already present within the project.
|
||||
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
|
||||
- Check the pull requests tab to ensure that the feature isn't already in progress.
|
||||
|
||||
Before submitting a pull request:
|
||||
|
||||
- Check the codebase to ensure that your feature doesn't already exist.
|
||||
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
|
||||
|
||||
## Requirements
|
||||
|
||||
If the project maintainer has any additional requirements, you will find them listed here.
|
||||
|
||||
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
|
||||
|
||||
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
|
||||
|
||||
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
|
||||
|
||||
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
|
||||
|
||||
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
|
||||
|
||||
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
|
||||
|
||||
**Happy coding**!
|
||||
21
vendor/spatie/laravel-image-optimizer/LICENSE.md
vendored
21
vendor/spatie/laravel-image-optimizer/LICENSE.md
vendored
@@ -1,21 +0,0 @@
|
||||
# The MIT License (MIT)
|
||||
|
||||
Copyright (c) Spatie bvba <info@spatie.be>
|
||||
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in
|
||||
> all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
> THE SOFTWARE.
|
||||
216
vendor/spatie/laravel-image-optimizer/README.md
vendored
216
vendor/spatie/laravel-image-optimizer/README.md
vendored
@@ -1,216 +0,0 @@
|
||||
# Optimize images in your Laravel app
|
||||
|
||||
[](https://packagist.org/packages/spatie/laravel-image-optimizer)
|
||||

|
||||
[](https://packagist.org/packages/spatie/laravel-image-optimizer)
|
||||
|
||||
This package is the Laravel 6.0 and up specific integration of [spatie/image-optimizer](https://github.com/spatie/image-optimizer). It can optimize PNGs, JPGs, SVGs and GIFs by running them through a chain of various [image optimization tools](https://github.com/spatie/image-optimizer#optimization-tools). The package will automatically detect which optimization binaries are installed on your system and use them.
|
||||
|
||||
Here's how you can use it:
|
||||
|
||||
```php
|
||||
use ImageOptimizer;
|
||||
|
||||
// the image will be replaced with an optimized version which should be smaller
|
||||
ImageOptimizer::optimize($pathToImage);
|
||||
|
||||
// if you use a second parameter the package will not modify the original
|
||||
ImageOptimizer::optimize($pathToImage, $pathToOptimizedImage);
|
||||
```
|
||||
|
||||
You don't like facades you say? No problem! Just resolve a configured instance of `Spatie\ImageOptimizer\OptimizerChain` out of the container:
|
||||
|
||||
```php
|
||||
app(Spatie\ImageOptimizer\OptimizerChain::class)->optimize($pathToImage);
|
||||
```
|
||||
|
||||
The package also contains [a middleware](https://github.com/spatie/laravel-image-optimizer/blob/master/README.md#using-the-middleware) to automatically optimize all images in an request.
|
||||
|
||||
Don't use Laravel you say? No problem! Just use the underlying [spatie/image-optimizer](https://github.com/spatie/image-optimizer) directly.
|
||||
|
||||
## Support us
|
||||
|
||||
[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/laravel-image-optimizer.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/laravel-image-optimizer)
|
||||
|
||||
We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
|
||||
|
||||
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
|
||||
|
||||
## Installation
|
||||
|
||||
You can install the package via composer:
|
||||
|
||||
```bash
|
||||
composer require spatie/laravel-image-optimizer
|
||||
```
|
||||
|
||||
The package will automatically register itself.
|
||||
|
||||
The package uses a bunch of binaries to optimize images. To learn which ones on how to install them, head over to the [optimization tools section](https://github.com/spatie/image-optimizer#optimization-tools) in the readme of the underlying image-optimizer package. That readme also contains info on [what these tools will do to your images](https://github.com/spatie/image-optimizer#which-tools-will-do-what).
|
||||
|
||||
The package comes with some sane defaults to optimize images. You can modify that configuration by publishing the config file.
|
||||
|
||||
```bash
|
||||
php artisan vendor:publish --provider="Spatie\LaravelImageOptimizer\ImageOptimizerServiceProvider"
|
||||
```
|
||||
|
||||
This is the contents of the `config/image-optimizer` file that will be published:
|
||||
|
||||
```php
|
||||
use Spatie\ImageOptimizer\Optimizers\Svgo;
|
||||
use Spatie\ImageOptimizer\Optimizers\Optipng;
|
||||
use Spatie\ImageOptimizer\Optimizers\Gifsicle;
|
||||
use Spatie\ImageOptimizer\Optimizers\Pngquant;
|
||||
use Spatie\ImageOptimizer\Optimizers\Jpegoptim;
|
||||
use Spatie\ImageOptimizer\Optimizers\Cwebp;
|
||||
|
||||
return [
|
||||
/**
|
||||
* When calling `optimize` the package will automatically determine which optimizers
|
||||
* should run for the given image.
|
||||
*/
|
||||
'optimizers' => [
|
||||
|
||||
Jpegoptim::class => [
|
||||
'-m85', // set maximum quality to 85%
|
||||
'--strip-all', // this strips out all text information such as comments and EXIF data
|
||||
'--all-progressive' // this will make sure the resulting image is a progressive one
|
||||
],
|
||||
|
||||
Pngquant::class => [
|
||||
'--force' // required parameter for this package
|
||||
],
|
||||
|
||||
Optipng::class => [
|
||||
'-i0', // this will result in a non-interlaced, progressive scanned image
|
||||
'-o2', // this set the optimization level to two (multiple IDAT compression trials)
|
||||
'-quiet' // required parameter for this package
|
||||
],
|
||||
|
||||
Svgo::class => [
|
||||
'--disable=cleanupIDs' // disabling because it is know to cause troubles
|
||||
],
|
||||
|
||||
Gifsicle::class => [
|
||||
'-b', // required parameter for this package
|
||||
'-O3' // this produces the slowest but best results
|
||||
],
|
||||
|
||||
Cwebp::class => [
|
||||
'-m 6', // for the slowest compression method in order to get the best compression.
|
||||
'-pass 10', // for maximizing the amount of analysis pass.
|
||||
'-mt', // multithreading for some speed improvements.
|
||||
'-q 90', //quality factor that brings the least noticeable changes.
|
||||
],
|
||||
],
|
||||
|
||||
/**
|
||||
* The maximum time in seconds each optimizer is allowed to run separately.
|
||||
*/
|
||||
'timeout' => 60,
|
||||
|
||||
/**
|
||||
* If set to `true` all output of the optimizer binaries will be appended to the default log.
|
||||
* You can also set this to a class that implements `Psr\Log\LoggerInterface`.
|
||||
*/
|
||||
'log_optimizer_activity' => false,
|
||||
];
|
||||
```
|
||||
|
||||
If you want to automatically optimize images that get uploaded to your application add the `\Spatie\LaravelImageOptimizer\Middlewares\OptimizeImages::class` in the http kernel.
|
||||
|
||||
```php
|
||||
// app/Http/Kernel.php
|
||||
protected $routeMiddleware = [
|
||||
...
|
||||
'optimizeImages' => \Spatie\LaravelImageOptimizer\Middlewares\OptimizeImages::class,
|
||||
];
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
You can resolve a configured instance of `Spatie\ImageOptimizer\OptimizerChain` out of the container:
|
||||
|
||||
```php
|
||||
// the image will be replaced with an optimized version which should be smaller
|
||||
app(Spatie\ImageOptimizer\OptimizerChain::class)->optimize($pathToImage);
|
||||
|
||||
// if you use a second parameter the package will not modify the original
|
||||
app(Spatie\ImageOptimizer\OptimizerChain::class)->optimize($pathToImage, $pathToOptimizedImage);
|
||||
```
|
||||
|
||||
### Using the facade
|
||||
|
||||
```php
|
||||
use ImageOptimizer;
|
||||
|
||||
// the image will be replaced with an optimized version which should be smaller
|
||||
ImageOptimizer::optimize($pathToImage);
|
||||
|
||||
// if you use a second parameter the package will not modify the original
|
||||
ImageOptimizer::optimize($pathToImage, $pathToOptimizedImage);
|
||||
```
|
||||
|
||||
You don't like facades you say? No problem! Just resolve a configured instance of `Spatie\ImageOptimizer\OptimizerChain` out of the container:
|
||||
|
||||
```php
|
||||
app(Spatie\ImageOptimizer\OptimizerChain::class)->optimize($pathToImage);
|
||||
```
|
||||
|
||||
### Using the middleware
|
||||
|
||||
All images that in requests to routes that use the `optimizeImages`-middleware will be optimized automatically.
|
||||
|
||||
```php
|
||||
Route::middleware('optimizeImages')->group(function () {
|
||||
// all images will be optimized automatically
|
||||
Route::post('upload-images', 'UploadController@index');
|
||||
});
|
||||
```
|
||||
|
||||
### Adding your own optimizers
|
||||
|
||||
To learn how to create your own optimizer read the ["Writing custom optimizers" section](https://github.com/spatie/image-optimizer#writing-a-custom-optimizers) in the readme of the underlying [spatie/image-optimizer](https://github.com/spatie/image-optimizer#writing-a-custom-optimizers) package.
|
||||
|
||||
You can add the fully qualified classname of your optimizer as a key in the `optimizers` array in the config file.
|
||||
|
||||
## Example conversions
|
||||
|
||||
Here are some [example conversions](https://github.com/spatie/image-optimizer#example-conversions) that were made by the optimizer.
|
||||
|
||||
## Changelog
|
||||
|
||||
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
|
||||
|
||||
## Testing
|
||||
|
||||
``` bash
|
||||
composer test
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
|
||||
|
||||
## Security
|
||||
|
||||
If you discover any security related issues, please email freek@spatie.be instead of using the issue tracker.
|
||||
|
||||
## Postcardware
|
||||
|
||||
You're free to use this package (it's [MIT-licensed](LICENSE.md)), but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.
|
||||
|
||||
Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.
|
||||
|
||||
We publish all received postcards [on our company website](https://spatie.be/en/opensource/postcards).
|
||||
|
||||
## Credits
|
||||
|
||||
- [Freek Van der Herten](https://github.com/freekmurze)
|
||||
- [All Contributors](../../contributors)
|
||||
|
||||
The idea of a middleware that optimizes all files in a request is taken from [approached/laravel-image-optimizer](https://github.com/approached/laravel-image-optimizer).
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
|
||||
@@ -1,56 +0,0 @@
|
||||
{
|
||||
"name": "spatie/laravel-image-optimizer",
|
||||
"description": "Optimize images in your Laravel app",
|
||||
"keywords": [
|
||||
"spatie",
|
||||
"laravel-image-optimizer"
|
||||
],
|
||||
"homepage": "https://github.com/spatie/laravel-image-optimizer",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Freek Van der Herten",
|
||||
"email": "freek@spatie.be",
|
||||
"homepage": "https://spatie.be",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2|^8.0",
|
||||
"laravel/framework": "^6.0|^7.0|^8.0",
|
||||
"spatie/image-optimizer": "^1.2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"orchestra/testbench": "^4.0|^5.0|^6.0",
|
||||
"phpunit/phpunit": "^9.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Spatie\\LaravelImageOptimizer\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Spatie\\LaravelImageOptimizer\\Test\\": "tests"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vendor/bin/phpunit",
|
||||
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes"
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Spatie\\LaravelImageOptimizer\\ImageOptimizerServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"ImageOptimizer": "Spatie\\LaravelImageOptimizer\\Facades\\ImageOptimizer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Spatie\ImageOptimizer\Optimizers\Cwebp;
|
||||
use Spatie\ImageOptimizer\Optimizers\Gifsicle;
|
||||
use Spatie\ImageOptimizer\Optimizers\Jpegoptim;
|
||||
use Spatie\ImageOptimizer\Optimizers\Optipng;
|
||||
use Spatie\ImageOptimizer\Optimizers\Pngquant;
|
||||
use Spatie\ImageOptimizer\Optimizers\Svgo;
|
||||
|
||||
return [
|
||||
/*
|
||||
* When calling `optimize` the package will automatically determine which optimizers
|
||||
* should run for the given image.
|
||||
*/
|
||||
'optimizers' => [
|
||||
|
||||
Jpegoptim::class => [
|
||||
'-m85', // set maximum quality to 85%
|
||||
'--strip-all', // this strips out all text information such as comments and EXIF data
|
||||
'--all-progressive', // this will make sure the resulting image is a progressive one
|
||||
],
|
||||
|
||||
Pngquant::class => [
|
||||
'--force', // required parameter for this package
|
||||
],
|
||||
|
||||
Optipng::class => [
|
||||
'-i0', // this will result in a non-interlaced, progressive scanned image
|
||||
'-o2', // this set the optimization level to two (multiple IDAT compression trials)
|
||||
'-quiet', // required parameter for this package
|
||||
],
|
||||
|
||||
Svgo::class => [
|
||||
'--disable=cleanupIDs', // disabling because it is know to cause troubles
|
||||
],
|
||||
|
||||
Gifsicle::class => [
|
||||
'-b', // required parameter for this package
|
||||
'-O3', // this produces the slowest but best results
|
||||
],
|
||||
|
||||
Cwebp::class => [
|
||||
'-m 6', // for the slowest compression method in order to get the best compression.
|
||||
'-pass 10', // for maximizing the amount of analysis pass.
|
||||
'-mt', // multithreading for some speed improvements.
|
||||
'-q 90', // quality factor that brings the least noticeable changes.
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
* The directory where your binaries are stored.
|
||||
* Only use this when you binaries are not accessible in the global environment.
|
||||
*/
|
||||
'binary_path' => '',
|
||||
|
||||
/*
|
||||
* The maximum time in seconds each optimizer is allowed to run separately.
|
||||
*/
|
||||
'timeout' => 60,
|
||||
|
||||
/*
|
||||
* If set to `true` all output of the optimizer binaries will be appended to the default log.
|
||||
* You can also set this to a class that implements `Psr\Log\LoggerInterface`.
|
||||
*/
|
||||
'log_optimizer_activity' => false,
|
||||
];
|
||||
@@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit bootstrap="vendor/autoload.php"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
verbose="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false">
|
||||
<testsuites>
|
||||
<testsuite name="Spatie Test Suite">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">src/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelImageOptimizer\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Spatie\ImageOptimizer\Optimizer;
|
||||
|
||||
class InvalidConfiguration extends Exception
|
||||
{
|
||||
public static function notAnOptimizer(string $class)
|
||||
{
|
||||
$optimizerInterface = Optimizer::class;
|
||||
|
||||
return new static("Configured optimizer `{$class}` does not implement `{$optimizerInterface}`.");
|
||||
}
|
||||
|
||||
public static function notAnLogger(string $class)
|
||||
{
|
||||
$loggerInterface = LoggerInterface::class;
|
||||
|
||||
return new static("Configured optimizer `{$class}` does not implement `{$loggerInterface}`.");
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelImageOptimizer\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class ImageOptimizer extends Facade
|
||||
{
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'image-optimizer';
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelImageOptimizer;
|
||||
|
||||
use Illuminate\Foundation\Application as LaravelApplication;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Laravel\Lumen\Application as LumenApplication;
|
||||
use Spatie\ImageOptimizer\OptimizerChain;
|
||||
|
||||
class ImageOptimizerServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function boot()
|
||||
{
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
$this->mergeConfigFrom(__DIR__.'/../config/image-optimizer.php', 'image-optimizer');
|
||||
|
||||
if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
|
||||
$this->publishes([
|
||||
__DIR__.'/../config/image-optimizer.php' => config_path('image-optimizer.php'),
|
||||
], 'config');
|
||||
}
|
||||
|
||||
if ($this->app instanceof LumenApplication) {
|
||||
$this->app->configure('image-optimizer');
|
||||
}
|
||||
|
||||
$this->app->bind(OptimizerChain::class, function () {
|
||||
return OptimizerChainFactory::create(config('image-optimizer'));
|
||||
});
|
||||
|
||||
$this->app->singleton('image-optimizer', OptimizerChain::class);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelImageOptimizer\Middlewares;
|
||||
|
||||
use Closure;
|
||||
use Spatie\ImageOptimizer\OptimizerChain;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
|
||||
class OptimizeImages
|
||||
{
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$optimizerChain = app(OptimizerChain::class);
|
||||
|
||||
collect($request->allFiles())
|
||||
->flatten()
|
||||
->filter(function (UploadedFile $file) {
|
||||
if (app()->environment('testing')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $file->isValid();
|
||||
})
|
||||
->each(function (UploadedFile $file) use ($optimizerChain) {
|
||||
$optimizerChain->optimize($file->getPathname());
|
||||
});
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelImageOptimizer;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Spatie\ImageOptimizer\DummyLogger;
|
||||
use Spatie\ImageOptimizer\Optimizer;
|
||||
use Spatie\ImageOptimizer\OptimizerChain;
|
||||
use Spatie\LaravelImageOptimizer\Exceptions\InvalidConfiguration;
|
||||
|
||||
class OptimizerChainFactory
|
||||
{
|
||||
public static function create(array $config)
|
||||
{
|
||||
return (new OptimizerChain())
|
||||
->useLogger(static::getLogger($config))
|
||||
->setTimeout($config['timeout'])
|
||||
->setOptimizers(static::getOptimizers($config));
|
||||
}
|
||||
|
||||
protected static function getLogger($config): LoggerInterface
|
||||
{
|
||||
$configuredLogger = $config['log_optimizer_activity'];
|
||||
|
||||
if ($configuredLogger === true) {
|
||||
return app('log');
|
||||
}
|
||||
|
||||
if ($configuredLogger === false) {
|
||||
return new DummyLogger();
|
||||
}
|
||||
|
||||
if (! is_a($configuredLogger, LoggerInterface::class, true)) {
|
||||
throw InvalidConfiguration::notAnLogger($configuredLogger);
|
||||
}
|
||||
|
||||
return new $configuredLogger;
|
||||
}
|
||||
|
||||
protected static function getOptimizers(array $config)
|
||||
{
|
||||
return collect($config['optimizers'])
|
||||
->mapWithKeys(function (array $options, string $optimizerClass) use ($config) {
|
||||
if (! is_a($optimizerClass, Optimizer::class, true)) {
|
||||
throw InvalidConfiguration::notAnOptimizer($optimizerClass);
|
||||
}
|
||||
|
||||
// Initialize optimizer class
|
||||
$newOptimizerClass = new $optimizerClass();
|
||||
|
||||
if (static::getBinaryPath($config)) {
|
||||
$newOptimizerClass->setBinaryPath(self::getBinaryPath($config));
|
||||
}
|
||||
|
||||
$newOptimizerClass->setOptions($options);
|
||||
|
||||
return [$optimizerClass => $newOptimizerClass];
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public static function getBinaryPath(array $config): string
|
||||
{
|
||||
return $config['binary_path'] ?? '';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user