From 8dceb8e3a75282540d7dbe9dc6e26091dad71fe0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 21 Nov 2017 14:30:26 -0800 Subject: thumbnail generator for epubs --- Zotlabs/Daemon/Thumbnail.php | 4 +++- Zotlabs/Thumbs/Epubthumb.php | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 Zotlabs/Thumbs/Epubthumb.php (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Thumbnail.php b/Zotlabs/Daemon/Thumbnail.php index caf5dd3ae..b3e539086 100644 --- a/Zotlabs/Daemon/Thumbnail.php +++ b/Zotlabs/Daemon/Thumbnail.php @@ -45,7 +45,9 @@ class Thumbnail { } } } - if(($default_controller) && (! file_exists(dbunescbin($attach['content']) . '.thumb'))) { + if(($default_controller) + && ((! file_exists(dbunescbin($attach['content']) . '.thumb')) + || (filectime(dbunescbin($attach['content']) . 'thumb') < (time() - 60)))) { $default_controller->Thumb($attach,$preview_style,$preview_width,$preview_height); } } diff --git a/Zotlabs/Thumbs/Epubthumb.php b/Zotlabs/Thumbs/Epubthumb.php new file mode 100644 index 000000000..4213b5267 --- /dev/null +++ b/Zotlabs/Thumbs/Epubthumb.php @@ -0,0 +1,38 @@ +Cover(); + + if($data['found']) { + $photo = $data['data']; + } + + if($photo) { + $image = imagecreatefromstring($photo); + $dest = imagecreatetruecolor( $width, $height ); + $srcwidth = imagesx($image); + $srcheight = imagesy($image); + + imagealphablending($dest, false); + imagesavealpha($dest, true); + imagecopyresampled($dest, $image, 0, 0, 0, 0, $width, $height, $srcwidth, $srcheight); + imagedestroy($image); + imagejpeg($dest,dbunescbin($attach['content']) . '.thumb'); + } + } +} + -- cgit v1.2.3