aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Thumbs/Epubthumb.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-11-22 15:43:48 -0800
committerzotlabs <mike@macgirvin.com>2017-11-22 15:43:48 -0800
commit9936670f44b53e391d997fd024faa329b8a0c803 (patch)
treea88c45c92843703049a91cf7b4ab4e374b52de97 /Zotlabs/Thumbs/Epubthumb.php
parent6ac3fc4e0724a881ed3b26fa8d0912f38512d2ca (diff)
parentb4f8f4df7bc5cc8a74240506cd536224cb31e114 (diff)
downloadvolse-hubzilla-9936670f44b53e391d997fd024faa329b8a0c803.tar.gz
volse-hubzilla-9936670f44b53e391d997fd024faa329b8a0c803.tar.bz2
volse-hubzilla-9936670f44b53e391d997fd024faa329b8a0c803.zip
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge
Diffstat (limited to 'Zotlabs/Thumbs/Epubthumb.php')
-rw-r--r--Zotlabs/Thumbs/Epubthumb.php38
1 files changed, 38 insertions, 0 deletions
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');
+ }
+ }
+}
+