Initial implementation for Thumbnails for PDFs / other things #6, requires ['pdf_file_thumbnail'] is set to true and using convert from imagemagick. If ['pdf_file_thumbnail'] is false then it uses standard configured static file icon

This commit is contained in:
Benjamin Southall 2017-03-05 01:41:52 +09:00
parent 5684461902
commit f3a5eb0940

View File

@ -985,6 +985,25 @@ if (isset($_POST['delete'])) {
} }
$image->destroy(); $image->destroy();
} else { } else {
if ($file['extension'] == "pdf" && $config['pdf_file_thumbnail']){
$path = $file['thumb'];
$error = shell_exec_error( 'convert -thumbnail x300 -background white -alpha remove ' .
escapeshellarg($file['tmp_name']. '[0]') . ' ' .
escapeshellarg($file['thumb']));
if ($error){
$path = sprintf($config['file_thumb'],isset($config['file_icons'][$file['extension']]) ? $config['file_icons'][$file['ext
ension']] : $config['file_icons']['default']);
}
$file['thumb'] = basename($file['thumb']);
$size = @getimagesize($path);
$file['thumbwidth'] = $size[0];
$file['thumbheight'] = $size[1];
$file['width'] = $size[0];
$file['height'] = $size[1];
}
else {
// not an image // not an image
//copy($config['file_thumb'], $post['thumb']); //copy($config['file_thumb'], $post['thumb']);
$file['thumb'] = 'file'; $file['thumb'] = 'file';
@ -995,6 +1014,7 @@ if (isset($_POST['delete'])) {
$file['thumbwidth'] = $size[0]; $file['thumbwidth'] = $size[0];
$file['thumbheight'] = $size[1]; $file['thumbheight'] = $size[1];
} }
}
if ($config['tesseract_ocr'] && $file['thumb'] != 'file') { // Let's OCR it! if ($config['tesseract_ocr'] && $file['thumb'] != 'file') { // Let's OCR it!
$fname = $file['tmp_name']; $fname = $file['tmp_name'];