aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Daemon/Thumbnail.php4
-rw-r--r--Zotlabs/Thumbs/Epubthumb.php38
2 files changed, 41 insertions, 1 deletions
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 @@
+<?php
+
+namespace Zotlabs\Thumbs;
+
+require_once('library/epub-meta/epub.php');
+
+class Epubthumb {
+
+ function Match($type) {
+ return(($type === 'application/epub+zip') ? true : false );
+ }
+
+ function Thumb($attach,$preview_style,$height = 300, $width = 300) {
+
+ $photo = false;
+
+ $ep = new \Epub(dbunescbin($attach['content']));
+ $data = $ep->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');
+ }
+ }
+}
+