mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 02:55:13 +00:00
38 lines
959 B
PHP
38 lines
959 B
PHP
<?php
|
|
|
|
namespace Code\Thumbs;
|
|
|
|
use wapmorgan\Mp3Info\Mp3Info;
|
|
|
|
class Mp3audio
|
|
{
|
|
|
|
public function Match($type)
|
|
{
|
|
return (($type === 'audio/mpeg') ? true : false);
|
|
}
|
|
|
|
public function Thumb($attach, $preview_style, $height = 300, $width = 300)
|
|
{
|
|
|
|
$audio = new Mp3Info($attach['content'], true);
|
|
if (! $audio->hasCover) {
|
|
return;
|
|
}
|
|
|
|
$photo = $audio->getCover();
|
|
|
|
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');
|
|
}
|
|
}
|
|
}
|