1
0
mirror of https://github.com/lrsjng/h5ai.git synced 2025-08-10 16:04:11 +02:00

Add gm support for PDF thumbs.

This commit is contained in:
Lars Jung
2015-05-14 19:00:10 +02:00
parent 89d56b3ae4
commit 99462d0ae0
3 changed files with 11 additions and 5 deletions

View File

@@ -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'
]);

View File

@@ -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')) {
} 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);

View File

@@ -106,8 +106,8 @@ modulejs.define('main/info', ['$', 'config', 'core/resource', 'core/server'], fu
);
addTest(
'PDF thumbs', 'Command line program <code>convert</code> available',
setup.HAS_CMD_CONVERT
'PDF thumbs', 'Command line program <code>convert</code> or <code>gm</code> available',
setup.HAS_CMD_CONVERT || setup.HAS_CMD_GM
);
addTest(