aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Thumbs
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-11-20 15:44:25 -0800
committerzotlabs <mike@macgirvin.com>2017-11-20 15:44:25 -0800
commit7f9ab491f29a71387bbbb066b9f6cea083d8813c (patch)
treee22042a6e4d751357b7979dbd11e9e959a0b45aa /Zotlabs/Thumbs
parent77190cca92239258931c40708d2b735b721754b5 (diff)
downloadvolse-hubzilla-7f9ab491f29a71387bbbb066b9f6cea083d8813c.tar.gz
volse-hubzilla-7f9ab491f29a71387bbbb066b9f6cea083d8813c.tar.bz2
volse-hubzilla-7f9ab491f29a71387bbbb066b9f6cea083d8813c.zip
add mp3 audio thumbnail generator
Diffstat (limited to 'Zotlabs/Thumbs')
-rw-r--r--Zotlabs/Thumbs/Mp3audio.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/Zotlabs/Thumbs/Mp3audio.php b/Zotlabs/Thumbs/Mp3audio.php
new file mode 100644
index 000000000..d2e660cf8
--- /dev/null
+++ b/Zotlabs/Thumbs/Mp3audio.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace Zotlabs\Thumbs;
+
+use ID3Parser\ID3Parser;
+
+class Mp3audio {
+
+ function Match($type) {
+ return(($type === 'audio/mpeg') ? true : false );
+ }
+
+ function Thumb($attach,$preview_style,$height = 300, $width = 300) {
+ $p = newID3Parser();
+
+ $id = $p->analyze(dbunescbin($attach['content']));
+
+ $photo = isset($id['id3v2']['APIC'][0]['data']) ? $id['id3v2']['APIC'][0]['data'] : null;
+ if(is_null($photo) && isset($id['id3v2']['PIC'][0]['data'])) {
+ $photo = $id['id3v2']['PIC'][0]['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');
+ }
+ }
+}
+