Upgrade to 3.6.2

This commit is contained in:
Bastian Allgeier
2022-02-01 11:42:39 +01:00
parent f62d1a39ca
commit 848ea36dcf
108 changed files with 2887 additions and 2622 deletions

View File

@@ -42,7 +42,7 @@ class ImageMagick extends Darkroom
protected function blur(string $file, array $options)
{
if ($options['blur'] !== false) {
return '-blur 0x' . $options['blur'];
return '-blur ' . escapeshellarg('0x' . $options['blur']);
}
}
@@ -69,7 +69,13 @@ class ImageMagick extends Darkroom
*/
protected function convert(string $file, array $options): string
{
return sprintf($options['bin'] . ' "%s"', $file);
$command = escapeshellarg($options['bin']);
// limit to single-threading to keep CPU usage sane
$command .= ' -limit thread 1';
// append input file
return $command . ' ' . escapeshellarg($file);
}
/**
@@ -162,7 +168,7 @@ class ImageMagick extends Darkroom
*/
protected function quality(string $file, array $options): string
{
return '-quality ' . $options['quality'];
return '-quality ' . escapeshellarg($options['quality']);
}
/**
@@ -177,7 +183,7 @@ class ImageMagick extends Darkroom
{
// simple resize
if ($options['crop'] === false) {
return sprintf('-thumbnail %sx%s!', $options['width'], $options['height']);
return '-thumbnail ' . escapeshellarg(sprintf('%sx%s!', $options['width'], $options['height']));
}
$gravities = [
@@ -195,15 +201,15 @@ class ImageMagick extends Darkroom
// translate the gravity option into something imagemagick understands
$gravity = $gravities[$options['crop']] ?? 'Center';
$command = sprintf('-thumbnail %sx%s^', $options['width'], $options['height']);
$command .= sprintf(' -gravity %s -crop %sx%s+0+0', $gravity, $options['width'], $options['height']);
$command = '-thumbnail ' . escapeshellarg(sprintf('%sx%s^', $options['width'], $options['height']));
$command .= ' -gravity ' . escapeshellarg($gravity);
$command .= ' -crop ' . escapeshellarg(sprintf('%sx%s+0+0', $options['width'], $options['height']));
return $command;
}
/**
* Makes sure to not process too many images at once
* which could crash the server
* Creates the option for the output file
*
* @param string $file
* @param array $options
@@ -215,7 +221,7 @@ class ImageMagick extends Darkroom
$file = pathinfo($file, PATHINFO_DIRNAME) . '/' . pathinfo($file, PATHINFO_FILENAME) . '.' . $options['format'];
}
return sprintf('-limit thread 1 "%s"', $file);
return escapeshellarg($file);
}
/**

View File

@@ -285,12 +285,12 @@ class Dimensions
if ($xml !== false) {
$attr = $xml->attributes();
$width = (float)($attr->width);
$height = (float)($attr->height);
if (($width === 0.0 || $height === 0.0) && empty($attr->viewBox) === false) {
$width = (int)($attr->width);
$height = (int)($attr->height);
if (($width === 0 || $height === 0) && empty($attr->viewBox) === false) {
$box = explode(' ', $attr->viewBox);
$width = (float)($box[2] ?? 0);
$height = (float)($box[3] ?? 0);
$width = (int)($box[2] ?? 0);
$height = (int)($box[3] ?? 0);
}
}