From 7f9ab491f29a71387bbbb066b9f6cea083d8813c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 20 Nov 2017 15:44:25 -0800 Subject: add mp3 audio thumbnail generator --- Zotlabs/Thumbs/Mp3audio.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Zotlabs/Thumbs/Mp3audio.php (limited to 'Zotlabs/Thumbs') 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 @@ +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'); + } + } +} + -- cgit v1.2.3