diff --git a/src/Manipulators/Brightness.php b/src/Manipulators/Brightness.php index f1d44971..2a33544e 100644 --- a/src/Manipulators/Brightness.php +++ b/src/Manipulators/Brightness.php @@ -5,7 +5,7 @@ use Intervention\Image\Image; /** - * @property string $bri + * @property string|null $bri */ class Brightness extends BaseManipulator { @@ -34,7 +34,7 @@ public function run(Image $image) */ public function getBrightness() { - if (!preg_match('/^-*[0-9]+$/', $this->bri)) { + if (null === $this->bri || !preg_match('/^-*[0-9]+$/', $this->bri)) { return; } diff --git a/src/Manipulators/Contrast.php b/src/Manipulators/Contrast.php index 38fc35c9..c2cf9140 100644 --- a/src/Manipulators/Contrast.php +++ b/src/Manipulators/Contrast.php @@ -5,7 +5,7 @@ use Intervention\Image\Image; /** - * @property string $con + * @property string|null $con */ class Contrast extends BaseManipulator { @@ -34,7 +34,7 @@ public function run(Image $image) */ public function getContrast() { - if (!preg_match('/^-*[0-9]+$/', $this->con)) { + if (null === $this->con || !preg_match('/^-*[0-9]+$/', $this->con)) { return; } diff --git a/src/Manipulators/Crop.php b/src/Manipulators/Crop.php index 78cfc228..9a8428df 100644 --- a/src/Manipulators/Crop.php +++ b/src/Manipulators/Crop.php @@ -5,7 +5,7 @@ use Intervention\Image\Image; /** - * @property string $crop + * @property string|null $crop */ class Crop extends BaseManipulator { @@ -45,6 +45,10 @@ public function run(Image $image) */ public function getCoordinates(Image $image) { + if (null === $this->crop) { + return; + } + $coordinates = explode(',', $this->crop); if (4 !== count($coordinates) or diff --git a/src/Manipulators/Gamma.php b/src/Manipulators/Gamma.php index 2242a909..035bb8de 100644 --- a/src/Manipulators/Gamma.php +++ b/src/Manipulators/Gamma.php @@ -5,7 +5,7 @@ use Intervention\Image\Image; /** - * @property string $gam + * @property string|null $gam */ class Gamma extends BaseManipulator { @@ -34,7 +34,7 @@ public function run(Image $image) */ public function getGamma() { - if (!preg_match('/^[0-9]\.*[0-9]*$/', $this->gam)) { + if (null === $this->gam || !preg_match('/^[0-9]\.*[0-9]*$/', $this->gam)) { return; } diff --git a/src/Manipulators/Size.php b/src/Manipulators/Size.php index 68493634..b5308829 100644 --- a/src/Manipulators/Size.php +++ b/src/Manipulators/Size.php @@ -5,10 +5,10 @@ use Intervention\Image\Image; /** - * @property string $dpr - * @property string $fit - * @property string $h - * @property string $w + * @property string $dpr + * @property string|null $fit + * @property string $h + * @property string $w */ class Size extends BaseManipulator { @@ -119,6 +119,10 @@ public function getHeight() */ public function getFit() { + if (null === $this->fit) { + return 'contain'; + } + if (in_array($this->fit, ['contain', 'fill', 'max', 'stretch'], true)) { return $this->fit; } @@ -424,6 +428,10 @@ public function getCrop() 'crop-bottom-right' => [100, 100, 1.0], ]; + if (null === $this->fit) { + return [50, 50, 1.0]; + } + if (array_key_exists($this->fit, $cropMethods)) { return $cropMethods[$this->fit]; } diff --git a/src/ServerFactory.php b/src/ServerFactory.php index a6819a29..778e7da0 100644 --- a/src/ServerFactory.php +++ b/src/ServerFactory.php @@ -57,13 +57,13 @@ public function getServer() $this->getApi() ); - $server->setSourcePathPrefix($this->getSourcePathPrefix()); - $server->setCachePathPrefix($this->getCachePathPrefix()); + $server->setSourcePathPrefix($this->getSourcePathPrefix() ?: ''); + $server->setCachePathPrefix($this->getCachePathPrefix() ?: ''); $server->setGroupCacheInFolders($this->getGroupCacheInFolders()); $server->setCacheWithFileExtensions($this->getCacheWithFileExtensions()); $server->setDefaults($this->getDefaults()); $server->setPresets($this->getPresets()); - $server->setBaseUrl($this->getBaseUrl()); + $server->setBaseUrl($this->getBaseUrl() ?: ''); $server->setResponseFactory($this->getResponseFactory()); if ($this->getTempDir()) { @@ -259,7 +259,7 @@ public function getManipulators() new Flip(), new Blur(), new Pixelate(), - new Watermark($this->getWatermarks(), $this->getWatermarksPathPrefix()), + new Watermark($this->getWatermarks(), $this->getWatermarksPathPrefix() ?: ''), new Background(), new Border(), new Encode(),