aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Thumbs/Epubthumb.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2018-01-09 09:00:20 +0100
committerMario <mario@mariovavti.com>2018-01-09 09:00:20 +0100
commit4f4d0e416eac87121898b8a27b1afa6065ff17a2 (patch)
treeaae7f2582b2b9c6596dcbf87c06a836434140830 /Zotlabs/Thumbs/Epubthumb.php
parent22c89b6c660e185d5c5c6362acf23b145d932d15 (diff)
parent8fde0f01b8472082158b38386046ed606bcfbc49 (diff)
downloadvolse-hubzilla-3.0.tar.gz
volse-hubzilla-3.0.tar.bz2
volse-hubzilla-3.0.zip
Merge branch '3.0RC'3.0
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');
+ }
+ }
+}
+