mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-21 23:43:17 +01:00
Add initial support for PDF thumbnails
This commit is contained in:
parent
42a28d1343
commit
e1e870c174
@ -308,12 +308,18 @@ function gd_image_load($file)
|
||||
return imagecreatefromwbmp($file);
|
||||
}
|
||||
}
|
||||
else if ($type == 'application' && strpos($image_type,'vnd.oasis.opendocument.') === 0)
|
||||
else if ($type == 'application')
|
||||
{
|
||||
// OpenDocuments have thumbnails inside already
|
||||
return get_opendocument_thumbnail($file);
|
||||
if(strpos($image_type,'vnd.oasis.opendocument.') === 0)
|
||||
{
|
||||
// OpenDocuments have thumbnails inside already
|
||||
return get_opendocument_thumbnail($file);
|
||||
}
|
||||
else if($image_type == 'pdf')
|
||||
{
|
||||
return get_pdf_thumbnail($file);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -366,6 +372,30 @@ function get_opendocument_thumbnail($file)
|
||||
return $image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the thumbnail from a PDF file and apply a colored mask
|
||||
* so you can tell what type it is, and so it looks a little better in larger
|
||||
* thumbnails (eg: in tiled view).
|
||||
*
|
||||
* Requires ImageMagick & ghostscript.
|
||||
*
|
||||
* @param string $file
|
||||
* @return resource GD image
|
||||
*/
|
||||
function get_pdf_thumbnail($file)
|
||||
{
|
||||
if(!class_exists('Imagick')) return false;
|
||||
|
||||
$im = new Imagick($file);
|
||||
$im->setimageformat('png');
|
||||
$im->setresolution(300, 300);
|
||||
|
||||
$gd = imagecreatefromstring($im->getimageblob());
|
||||
//$mask = imagecreatefrompng('templates/default/images/mask_pdf.png');
|
||||
//imagecopyresampled($image, $mask,0,0,0,0,imagesx($mask),imagesy($mask),imagesx($mask),imagesy($mask));
|
||||
return $gd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an gd_image with transparent background.
|
||||
*
|
||||
|
@ -135,7 +135,7 @@ egw.extend('images', egw.MODULE_GLOBAL, function() {
|
||||
|
||||
}
|
||||
else if (typeof _path == 'string' && (type[0] == 'image' && type[1].match(/^(png|jpe?g|gif|bmp)$/) ||
|
||||
type[0] == 'application' && type[1].indexOf('vnd.oasis.opendocument.') === 0))
|
||||
type[0] == 'application' && (type[1].indexOf('vnd.oasis.opendocument.') === 0 || type[1] == 'pdf')))
|
||||
{
|
||||
var thsize = this.config('link_list_thumbnail') || 64;
|
||||
image = this.link('/etemplate/thumbnail.php',{ 'path': _path, 'thsize': thsize});
|
||||
|
Loading…
Reference in New Issue
Block a user