From 99462d0ae0b97f1c1af07812afe89bc470c42468 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Thu, 14 May 2015 19:00:10 +0200 Subject: [PATCH] Add gm support for PDF thumbs. --- src/_h5ai/backend/php/core/class-setup.php | 3 ++- src/_h5ai/backend/php/ext/class-thumb.php | 9 +++++++-- src/_h5ai/public/js/inc/main/info.js | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/_h5ai/backend/php/core/class-setup.php b/src/_h5ai/backend/php/core/class-setup.php index 9ef1dc7d..59618842 100644 --- a/src/_h5ai/backend/php/core/class-setup.php +++ b/src/_h5ai/backend/php/core/class-setup.php @@ -135,7 +135,7 @@ class Setup { $cmd = 'which'; } - foreach (['avconv', 'convert', 'du', 'ffmpeg', 'tar', 'zip'] as $c) { + foreach (['avconv', 'convert', 'du', 'ffmpeg', 'gm', 'tar', 'zip'] as $c) { $cmds[$c] = ($cmd !== false) && Util::exec_0($cmd . ' ' . $c); } @@ -175,6 +175,7 @@ class Setup { 'HAS_CMD_CONVERT', 'HAS_CMD_DU', 'HAS_CMD_FFMPEG', + 'HAS_CMD_GM', 'HAS_CMD_TAR', 'HAS_CMD_ZIP' ]); diff --git a/src/_h5ai/backend/php/ext/class-thumb.php b/src/_h5ai/backend/php/ext/class-thumb.php index 65ee9504..71c3bbf7 100644 --- a/src/_h5ai/backend/php/ext/class-thumb.php +++ b/src/_h5ai/backend/php/ext/class-thumb.php @@ -5,6 +5,7 @@ class Thumb { private static $FFMPEG_CMDV = ['ffmpeg', '-ss', '0:00:10', '-i', '[SRC]', '-an', '-vframes', '1', '[DEST]']; private static $AVCONV_CMDV = ['avconv', '-ss', '0:00:10', '-i', '[SRC]', '-an', '-vframes', '1', '[DEST]']; private static $CONVERT_CMDV = ['convert', '-density', '200', '-quality', '100', '-sharpen', '0x1.0', '-strip', '[SRC][0]', '[DEST]']; + private static $GM_CONVERT_CMDV = ['gm', 'convert', '-density', '200', '-quality', '100', '-sharpen', '0x1.0', '[SRC][0]', '[DEST]']; private static $THUMB_CACHE = 'thumbs'; private $context; @@ -40,8 +41,12 @@ class Thumb { } else if ($this->setup->get('HAS_CMD_FFMPEG')) { $capture_path = $this->capture(Thumb::$FFMPEG_CMDV, $source_path); } - } else if ($type === 'doc' && $this->setup->get('HAS_CMD_CONVERT')) { - $capture_path = $this->capture(Thumb::$CONVERT_CMDV, $source_path); + } else if ($type === 'doc') { + if ($this->setup->get('HAS_CMD_CONVERT')) { + $capture_path = $this->capture(Thumb::$CONVERT_CMDV, $source_path); + } else if ($this->setup->get('HAS_CMD_GM')) { + $capture_path = $this->capture(Thumb::$GM_CONVERT_CMDV, $source_path); + } } return $this->thumb_href($capture_path, $width, $height); diff --git a/src/_h5ai/public/js/inc/main/info.js b/src/_h5ai/public/js/inc/main/info.js index c4532845..cacac055 100644 --- a/src/_h5ai/public/js/inc/main/info.js +++ b/src/_h5ai/public/js/inc/main/info.js @@ -106,8 +106,8 @@ modulejs.define('main/info', ['$', 'config', 'core/resource', 'core/server'], fu ); addTest( - 'PDF thumbs', 'Command line program convert available', - setup.HAS_CMD_CONVERT + 'PDF thumbs', 'Command line program convert or gm available', + setup.HAS_CMD_CONVERT || setup.HAS_CMD_GM ); addTest(