Skip to content
This repository has been archived by the owner on Jan 5, 2018. It is now read-only.

Commit

Permalink
git commit -m 'Issue #2848823 by mondrake: Imagemagick: '\''convert'\…
Browse files Browse the repository at this point in the history
…'' hangs if file local path is missing' --author="mondrake <[email protected]>"
  • Loading branch information
mondrake committed Feb 2, 2017
1 parent 7e79819 commit e16b53b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/Plugin/ImageToolkit/Operation/imagemagick/Background.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ class Background extends ImagemagickImageToolkitOperationBase {
* {@inheritdoc}
*/
protected function execute(array $arguments) {
// Background image local path.
$local_path = $arguments['background_image']->getToolkit()->getSourceLocalPath();
if ($local_path !== '') {
$image_path = $this->getToolkit()->escapeShellArg($local_path);
}
else {
$source_path = $arguments['background_image']->getToolkit()->getSource();
throw new \InvalidArgumentException("Missing local path for image at {$source_path}");
}

// Reset any gravity settings from earlier effects.
$op = '-gravity None';

Expand All @@ -39,7 +49,7 @@ protected function execute(array $arguments) {
$op .= " -extent {$w}x{$h}{$x}{$y} ";

// Add the background image.
$op .= $this->getToolkit()->escapeShellArg($arguments['background_image']->getToolkit()->getSourceLocalPath());
$op .= $image_path;

// Compose it with the destination.
if ($arguments['opacity'] == 100) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ class ReplaceImage extends ImagemagickImageToolkitOperationBase {
*/
protected function execute(array $arguments) {
$replacement = $arguments['replacement_image'];

// Replacement image local path.
$local_path = $replacement->getToolkit()->getSourceLocalPath();
if ($local_path === '') {
$source_path = $replacement->getToolkit()->getSource();
throw new \InvalidArgumentException("Missing local path for image at {$source_path}");
}

$this->getToolkit()
->resetArguments()
->setSourceLocalPath($replacement->getToolkit()->getSourceLocalPath())
Expand Down
11 changes: 9 additions & 2 deletions src/Plugin/ImageToolkit/Operation/imagemagick/Watermark.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ class Watermark extends ImagemagickImageToolkitOperationBase {
* {@inheritdoc}
*/
protected function execute(array $arguments) {
// Overlay image path.
$image_path = $this->getToolkit()->escapeShellArg($arguments['watermark_image']->getToolkit()->getSourceLocalPath());
// Overlay image local path.
$local_path = $arguments['watermark_image']->getToolkit()->getSourceLocalPath();
if ($local_path !== '') {
$image_path = $this->getToolkit()->escapeShellArg($local_path);
}
else {
$source_path = $arguments['watermark_image']->getToolkit()->getSource();
throw new \InvalidArgumentException("Missing local path for image at {$source_path}");
}

// Set the dimensions of the overlay. Use of the scale option means that we
// need to change the dimensions: always set them, they don't harm when the
Expand Down

0 comments on commit e16b53b

Please sign in to comment.