Subiendo proyecto completo sin restricciones de git ignore
This commit is contained in:
55
vendor/spatie/laravel-image-optimizer/.github/CONTRIBUTING.md
vendored
Normal file
55
vendor/spatie/laravel-image-optimizer/.github/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
# 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
vendor/spatie/laravel-image-optimizer/.github/FUNDING.yml
vendored
Normal file
1
vendor/spatie/laravel-image-optimizer/.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
custom: https://spatie.be/open-source/support-us
|
||||
23
vendor/spatie/laravel-image-optimizer/.github/workflows/php-cs-fixer.yml
vendored
Normal file
23
vendor/spatie/laravel-image-optimizer/.github/workflows/php-cs-fixer.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
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
|
||||
57
vendor/spatie/laravel-image-optimizer/.github/workflows/run-tests.yml
vendored
Normal file
57
vendor/spatie/laravel-image-optimizer/.github/workflows/run-tests.yml
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
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
|
||||
37
vendor/spatie/laravel-image-optimizer/.php_cs.dist
vendored
Normal file
37
vendor/spatie/laravel-image-optimizer/.php_cs.dist
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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);
|
||||
72
vendor/spatie/laravel-image-optimizer/CHANGELOG.md
vendored
Normal file
72
vendor/spatie/laravel-image-optimizer/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
# 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
|
||||
55
vendor/spatie/laravel-image-optimizer/CONTRIBUTING.md
vendored
Normal file
55
vendor/spatie/laravel-image-optimizer/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
# 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
Normal file
21
vendor/spatie/laravel-image-optimizer/LICENSE.md
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# 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
Normal file
216
vendor/spatie/laravel-image-optimizer/README.md
vendored
Normal file
@@ -0,0 +1,216 @@
|
||||
# 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.
|
||||
56
vendor/spatie/laravel-image-optimizer/composer.json
vendored
Normal file
56
vendor/spatie/laravel-image-optimizer/composer.json
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
66
vendor/spatie/laravel-image-optimizer/config/image-optimizer.php
vendored
Normal file
66
vendor/spatie/laravel-image-optimizer/config/image-optimizer.php
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
<?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,
|
||||
];
|
||||
22
vendor/spatie/laravel-image-optimizer/phpunit.xml.dist.bak
vendored
Normal file
22
vendor/spatie/laravel-image-optimizer/phpunit.xml.dist.bak
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?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>
|
||||
24
vendor/spatie/laravel-image-optimizer/src/Exceptions/InvalidConfiguration.php
vendored
Normal file
24
vendor/spatie/laravel-image-optimizer/src/Exceptions/InvalidConfiguration.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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}`.");
|
||||
}
|
||||
}
|
||||
13
vendor/spatie/laravel-image-optimizer/src/Facades/ImageOptimizer.php
vendored
Normal file
13
vendor/spatie/laravel-image-optimizer/src/Facades/ImageOptimizer.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelImageOptimizer\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class ImageOptimizer extends Facade
|
||||
{
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'image-optimizer';
|
||||
}
|
||||
}
|
||||
36
vendor/spatie/laravel-image-optimizer/src/ImageOptimizerServiceProvider.php
vendored
Normal file
36
vendor/spatie/laravel-image-optimizer/src/ImageOptimizerServiceProvider.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
30
vendor/spatie/laravel-image-optimizer/src/Middlewares/OptimizeImages.php
vendored
Normal file
30
vendor/spatie/laravel-image-optimizer/src/Middlewares/OptimizeImages.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
66
vendor/spatie/laravel-image-optimizer/src/OptimizerChainFactory.php
vendored
Normal file
66
vendor/spatie/laravel-image-optimizer/src/OptimizerChainFactory.php
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
<?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