Upgrade to 3.2.0

This commit is contained in:
Bastian Allgeier
2019-06-25 09:56:08 +02:00
parent 9e18cf635d
commit 9c89153d35
296 changed files with 14408 additions and 2504 deletions

View File

@@ -3,14 +3,14 @@
namespace Kirby\Image;
/**
* Small class which hold info about the camera
*
* @package Kirby Toolkit
* @author Bastian Allgeier <bastian@getkirby.com>
* @link http://getkirby.com
* @copyright Bastian Allgeier
* @license MIT
*/
* Small class which hold info about the camera
*
* @package Kirby Image
* @author Bastian Allgeier <bastian@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier GmbH
* @license https://opensource.org/licenses/MIT
*/
class Camera
{
@@ -83,7 +83,7 @@ class Camera
}
/**
* Improved var_dump() output
* Improved `var_dump` output
*
* @return array
*/

View File

@@ -7,6 +7,12 @@ use Exception;
/**
* A wrapper around resizing and cropping
* via GDLib, ImageMagick or other libraries.
*
* @package Kirby Image
* @author Bastian Allgeier <bastian@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier GmbH
* @license https://opensource.org/licenses/MIT
*/
class Darkroom
{

View File

@@ -8,6 +8,15 @@ use Exception;
use claviska\SimpleImage;
use Kirby\Image\Darkroom;
/**
* GdLib
*
* @package Kirby Image
* @author Bastian Allgeier <bastian@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier GmbH
* @license https://opensource.org/licenses/MIT
*/
class GdLib extends Darkroom
{
public function process(string $file, array $options = []): array

View File

@@ -6,16 +6,17 @@ use Exception;
use Kirby\Image\Darkroom;
use Kirby\Toolkit\F;
/**
* ImageMagick
*
* @package Kirby Image
* @author Bastian Allgeier <bastian@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier GmbH
* @license https://opensource.org/licenses/MIT
*/
class ImageMagick extends Darkroom
{
protected function defaults(): array
{
return parent::defaults() + [
'bin' => 'convert',
'interlace' => false,
];
}
protected function autoOrient(string $file, array $options)
{
if ($options['autoOrient'] === true) {
@@ -42,6 +43,14 @@ class ImageMagick extends Darkroom
return sprintf($options['bin'] . ' "%s"', $file);
}
protected function defaults(): array
{
return parent::defaults() + [
'bin' => 'convert',
'interlace' => false,
];
}
protected function grayscale(string $file, array $options)
{
if ($options['grayscale'] === true) {
@@ -80,7 +89,7 @@ class ImageMagick extends Darkroom
// log broken commands
if ($return !== 0) {
error_log('The imagemagick convert command could not be executed: ' . $command);
throw new Exception('The imagemagick convert command could not be executed: ' . $command);
}
return $options;

View File

@@ -10,9 +10,9 @@ namespace Kirby\Image;
*
* @package Kirby Image
* @author Bastian Allgeier <bastian@getkirby.com>
* @link http://getkirby.com
* @copyright Bastian Allgeier
* @license MIT
* @link https://getkirby.com
* @copyright Bastian Allgeier GmbH
* @license https://opensource.org/licenses/MIT
*/
class Dimensions
{
@@ -44,7 +44,7 @@ class Dimensions
}
/**
* Improved var_dump() output
* Improved `var_dump` output
*
* @return array
*/
@@ -68,9 +68,9 @@ class Dimensions
*
* @param int $width
* @param int $height
* @return Dimensions
* @return self
*/
public function crop(int $width, int $height = null): self
public function crop(int $width, int $height = null)
{
$this->width = $width;
$this->height = $width;
@@ -111,9 +111,9 @@ class Dimensions
* @param int $box the max width and/or height
* @param bool $force If true, the dimensions will be
* upscaled to fit the box if smaller
* @return Dimensions object with recalculated dimensions
* @return self object with recalculated dimensions
*/
public function fit(int $box, bool $force = false): self
public function fit(int $box, bool $force = false)
{
if ($this->width == 0 || $this->height == 0) {
$this->width = $box;
@@ -163,9 +163,9 @@ class Dimensions
* @param int $fit the max height
* @param bool $force If true, the dimensions will be
* upscaled to fit the box if smaller
* @return Dimensions object with recalculated dimensions
* @return self object with recalculated dimensions
*/
public function fitHeight(int $fit = null, bool $force = false): self
public function fitHeight(int $fit = null, bool $force = false)
{
return $this->fitSize('height', $fit, $force);
}
@@ -177,9 +177,9 @@ class Dimensions
* @param int $fit the max width
* @param bool $force If true, the dimensions will be
* upscaled to fit the box if smaller
* @return Dimensions object with recalculated dimensions
* @return self object with recalculated dimensions
*/
protected function fitSize(string $ref, int $fit = null, bool $force = false): self
protected function fitSize(string $ref, int $fit = null, bool $force = false)
{
if ($fit === 0 || $fit === null) {
return $this;
@@ -216,9 +216,9 @@ class Dimensions
* @param int $fit the max width
* @param bool $force If true, the dimensions will be
* upscaled to fit the box if smaller
* @return Dimensions object with recalculated dimensions
* @return self object with recalculated dimensions
*/
public function fitWidth(int $fit = null, bool $force = false): self
public function fitWidth(int $fit = null, bool $force = false)
{
return $this->fitSize('width', $fit, $force);
}
@@ -229,9 +229,9 @@ class Dimensions
* @param int $width the max height
* @param int $height the max width
* @param bool $force
* @return Dimensions
* @return self
*/
public function fitWidthAndHeight(int $width = null, int $height = null, bool $force = false): self
public function fitWidthAndHeight(int $width = null, int $height = null, bool $force = false)
{
if ($this->width > $this->height) {
$this->fitWidth($width, $force);
@@ -258,7 +258,7 @@ class Dimensions
* @param string $root
* @return self
*/
public static function forImage(string $root): self
public static function forImage(string $root)
{
if (file_exists($root) === false) {
return new static(0, 0);
@@ -274,7 +274,7 @@ class Dimensions
* @param string $root
* @return self
*/
public static function forSvg(string $root): self
public static function forSvg(string $root)
{
// avoid xml errors
libxml_use_internal_errors(true);
@@ -366,9 +366,9 @@ class Dimensions
* @param int $width
* @param int $height
* @param bool $force
* @return Dimensions
* @return self
*/
public function resize(int $width = null, int $height = null, bool $force = false): self
public function resize(int $width = null, int $height = null, bool $force = false)
{
return $this->fitWidthAndHeight($width, $height, $force);
}

View File

@@ -9,9 +9,9 @@ use Kirby\Toolkit\V;
*
* @package Kirby Image
* @author Bastian Allgeier <bastian@getkirby.com>
* @link http://getkirby.com
* @copyright Bastian Allgeier
* @license MIT
* @link https://getkirby.com
* @copyright Bastian Allgeier GmbH
* @license https://opensource.org/licenses/MIT
*/
class Exif
{
@@ -84,7 +84,7 @@ class Exif
/**
* Constructor
*
* @param Image $image
* @param Kirby\Image\Image $image
*/
public function __construct(Image $image)
{
@@ -106,7 +106,7 @@ class Exif
/**
* Returns the Camera object
*
* @return Camera|null
* @return Kirby\Image\Camera|null
*/
public function camera()
{
@@ -120,7 +120,7 @@ class Exif
/**
* Returns the location object
*
* @return Location|null
* @return Kirby\Image\Location|null
*/
public function location()
{
@@ -283,7 +283,7 @@ class Exif
}
/**
* Improved var_dump() output
* Improved `var_dump` output
*
* @return array
*/

View File

@@ -18,9 +18,9 @@ use Kirby\Toolkit\V;
*
* @package Kirby Image
* @author Bastian Allgeier <bastian@getkirby.com>
* @link http://getkirby.com
* @copyright Bastian Allgeier
* @license MIT
* @link https://getkirby.com
* @copyright Bastian Allgeier GmbH
* @license https://opensource.org/licenses/MIT
*/
class Image extends File
{
@@ -54,7 +54,7 @@ class Image extends File
}
/**
* Improved var_dump() output
* Improved `var_dump` output
*
* @return array
*/
@@ -80,15 +80,15 @@ class Image extends File
/**
* Returns the dimensions of the file if possible
*
* @return Dimensions
* @return Kirby\Image\Dimensions
*/
public function dimensions(): Dimensions
public function dimensions()
{
if ($this->dimensions !== null) {
return $this->dimensions;
}
if (in_array($this->mime(), ['image/jpeg', 'image/png', 'image/gif'])) {
if (in_array($this->mime(), ['image/jpeg', 'image/jp2', 'image/png', 'image/gif'])) {
return $this->dimensions = Dimensions::forImage($this->root);
}
@@ -114,9 +114,9 @@ class Image extends File
/**
* Returns the exif object for this file (if image)
*
* @return Exif
* @return Kirby\Image\Exif
*/
public function exif(): Exif
public function exif()
{
if ($this->exif !== null) {
return $this->exif;
@@ -129,7 +129,7 @@ class Image extends File
* Sends an appropriate header for the asset
*
* @param boolean $send
* @return Response|string
* @return Kirby\Http\Response|string
*/
public function header(bool $send = true)
{

View File

@@ -3,15 +3,15 @@
namespace Kirby\Image;
/**
* Returns the latitude and longitude values
* for exif location data if available
*
* @package Kirby Toolkit
* @author Bastian Allgeier <bastian@getkirby.com>
* @link http://getkirby.com
* @copyright Bastian Allgeier
* @license MIT
*/
* Returns the latitude and longitude values
* for exif location data if available
*
* @package Kirby Image
* @author Bastian Allgeier <bastian@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier GmbH
* @license https://opensource.org/licenses/MIT
*/
class Location
{
@@ -126,7 +126,7 @@ class Location
}
/**
* Improved var_dump() output
* Improved `var_dump` output
*
* @return array
*/