Subiendo proyecto completo sin restricciones de git ignore
This commit is contained in:
56
vendor/spatie/image-optimizer/src/Optimizers/BaseOptimizer.php
vendored
Normal file
56
vendor/spatie/image-optimizer/src/Optimizers/BaseOptimizer.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
24
vendor/spatie/image-optimizer/src/Optimizers/Cwebp.php
vendored
Normal file
24
vendor/spatie/image-optimizer/src/Optimizers/Cwebp.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
24
vendor/spatie/image-optimizer/src/Optimizers/Gifsicle.php
vendored
Normal file
24
vendor/spatie/image-optimizer/src/Optimizers/Gifsicle.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
15
vendor/spatie/image-optimizer/src/Optimizers/Jpegoptim.php
vendored
Normal file
15
vendor/spatie/image-optimizer/src/Optimizers/Jpegoptim.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?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';
|
||||
}
|
||||
}
|
||||
15
vendor/spatie/image-optimizer/src/Optimizers/Optipng.php
vendored
Normal file
15
vendor/spatie/image-optimizer/src/Optimizers/Optipng.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?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';
|
||||
}
|
||||
}
|
||||
24
vendor/spatie/image-optimizer/src/Optimizers/Pngquant.php
vendored
Normal file
24
vendor/spatie/image-optimizer/src/Optimizers/Pngquant.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
33
vendor/spatie/image-optimizer/src/Optimizers/Svgo.php
vendored
Normal file
33
vendor/spatie/image-optimizer/src/Optimizers/Svgo.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user