Upgrade to 3.6.3

This commit is contained in:
Bastian Allgeier
2022-03-22 10:43:28 +01:00
parent 15da803094
commit f732a03566
275 changed files with 1961 additions and 1126 deletions

View File

@@ -8,7 +8,7 @@ namespace Kirby\Image;
* @package Kirby Image
* @author Bastian Allgeier <bastian@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier GmbH
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*/
class Camera

View File

@@ -11,7 +11,7 @@ use Exception;
* @package Kirby Image
* @author Bastian Allgeier <bastian@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier GmbH
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*/
class Darkroom
@@ -63,14 +63,16 @@ class Darkroom
protected function defaults(): array
{
return [
'autoOrient' => true,
'blur' => false,
'crop' => false,
'format' => null,
'grayscale' => false,
'height' => null,
'quality' => 90,
'width' => null,
'autoOrient' => true,
'blur' => false,
'crop' => false,
'format' => null,
'grayscale' => false,
'height' => null,
'quality' => 90,
'scaleHeight' => null,
'scaleWidth' => null,
'width' => null,
];
}
@@ -124,12 +126,21 @@ class Darkroom
*/
public function preprocess(string $file, array $options = [])
{
$options = $this->options($options);
$image = new Image($file);
$dimensions = $image->dimensions()->thumb($options);
$options = $this->options($options);
$image = new Image($file);
$options['width'] = $dimensions->width();
$options['height'] = $dimensions->height();
$dimensions = $image->dimensions();
$thumbDimensions = $dimensions->thumb($options);
$sourceWidth = $image->width();
$sourceHeight = $image->height();
$options['width'] = $thumbDimensions->width();
$options['height'] = $thumbDimensions->height();
// scale ratio compared to the source dimensions
$options['scaleWidth'] = $sourceWidth ? $options['width'] / $sourceWidth : null;
$options['scaleHeight'] = $sourceHeight ? $options['height'] / $sourceHeight : null;
return $options;
}

View File

@@ -12,7 +12,7 @@ use Kirby\Image\Darkroom;
* @package Kirby Image
* @author Bastian Allgeier <bastian@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier GmbH
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*/
class GdLib extends Darkroom

View File

@@ -12,7 +12,7 @@ use Kirby\Image\Darkroom;
* @package Kirby Image
* @author Bastian Allgeier <bastian@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier GmbH
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*/
class ImageMagick extends Darkroom
@@ -74,6 +74,14 @@ class ImageMagick extends Darkroom
// limit to single-threading to keep CPU usage sane
$command .= ' -limit thread 1';
// add JPEG size hint to optimize CPU and memory usage
if (F::mime($file) === 'image/jpeg') {
// add hint only when downscaling
if ($options['scaleWidth'] < 1 && $options['scaleHeight'] < 1) {
$command .= ' -define ' . escapeshellarg(sprintf('jpeg:size=%dx%d', $options['width'], $options['height']));
}
}
// append input file
return $command . ' ' . escapeshellarg($file);
}

View File

@@ -11,7 +11,7 @@ namespace Kirby\Image;
* @package Kirby Image
* @author Bastian Allgeier <bastian@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier GmbH
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*/
class Dimensions

View File

@@ -10,7 +10,7 @@ use Kirby\Toolkit\V;
* @package Kirby Image
* @author Bastian Allgeier <bastian@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier GmbH
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*/
class Exif

View File

@@ -17,7 +17,7 @@ use Kirby\Toolkit\Html;
* @package Kirby Image
* @author Nico Hoffmann <nico@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier GmbH
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*/
class Image extends File

View File

@@ -9,7 +9,7 @@ namespace Kirby\Image;
* @package Kirby Image
* @author Bastian Allgeier <bastian@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier GmbH
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*/
class Location