mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-21 16:55:13 +00:00
43 lines
954 B
PHP
43 lines
954 B
PHP
<?php
|
|
|
|
namespace Zotlabs\Thumbs;
|
|
|
|
use PhpId3\Id3TagsReader;
|
|
|
|
class Mp3audio {
|
|
|
|
function Match($type) {
|
|
return(($type === 'audio/mpeg') ? true : false );
|
|
}
|
|
|
|
function Thumb($attach,$preview_style,$height = 300, $width = 300) {
|
|
|
|
$fh = @fopen(dbunescbin($attach['content']),'rb');
|
|
if ($fh === false) {
|
|
return;
|
|
}
|
|
$id3 = new Id3TagsReader($fh);
|
|
$id3->readAllTags();
|
|
|
|
$image = $id3->getImage();
|
|
if (is_array($image)) {
|
|
$photo = $image[1];
|
|
}
|
|
|
|
fclose($fh);
|
|
|
|
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');
|
|
}
|
|
}
|
|
}
|
|
|