summaryrefslogtreecommitdiffstats
path: root/application/libraries/Image/Drivers/imagemagick.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2015-05-27 00:18:45 +0200
committerFlorian Pritz <bluewind@xinu.at>2015-05-28 18:10:13 +0200
commit33321b43cafbb731bff062aeffd6f46e38749faf (patch)
tree201c2296022f015d686368537dde36ea7d7b1ab1 /application/libraries/Image/Drivers/imagemagick.php
parentd00027bbba30a7693135c8b7cb5de267e8c478d4 (diff)
Improve running of external commands
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/libraries/Image/Drivers/imagemagick.php')
-rw-r--r--application/libraries/Image/Drivers/imagemagick.php16
1 files changed, 4 insertions, 12 deletions
diff --git a/application/libraries/Image/Drivers/imagemagick.php b/application/libraries/Image/Drivers/imagemagick.php
index ed0c70dc6..e37b9c8b3 100644
--- a/application/libraries/Image/Drivers/imagemagick.php
+++ b/application/libraries/Image/Drivers/imagemagick.php
@@ -45,13 +45,6 @@ class imagemagick implements \libraries\Image\ImageDriver {
$this->arguments = array();
}
- private function passthru($arguments)
- {
- $command_string = implode(" ", array_map("escapeshellarg", $arguments));
- passthru($command_string, $ret);
- return $ret;
- }
-
public function get($target_type = null)
{
if ($target_type === null) {
@@ -62,7 +55,6 @@ class imagemagick implements \libraries\Image\ImageDriver {
$command = array_merge($command, $this->arguments);
$command[] = $this->source_file."[0]";
- ob_start();
switch ($target_type) {
case IMAGETYPE_GIF:
$command[] = "gif:-";
@@ -76,14 +68,14 @@ class imagemagick implements \libraries\Image\ImageDriver {
default:
assert(0);
}
- $ret = $this->passthru($command);
- $result = ob_get_clean();
- if ($ret != 0 || $result === false) {
+ try {
+ $ret = (new \libraries\ProcRunner($command))->execSafe();
+ } catch (\exceptions\ApiException $e) {
throw new \exceptions\ApiException("libraries/Image/thumbnail-creation-failed", "Failed to create thumbnail");
}
- return $result;
+ return $ret["stdout"];
}
public function resize($width, $height)