2017-11-20 23:44:25 +00:00
|
|
|
<?php
|
|
|
|
|
2022-02-16 04:08:28 +00:00
|
|
|
namespace Code\Thumbs;
|
2017-11-20 23:44:25 +00:00
|
|
|
|
2020-06-16 01:01:20 +00:00
|
|
|
require_once('library/php-id3/PhpId3/Id3TagsReader.php');
|
|
|
|
require_once('library/php-id3/PhpId3/BinaryFileReader.php');
|
|
|
|
require_once('library/php-id3/PhpId3/Id3Tags.php');
|
|
|
|
|
2020-02-05 03:51:35 +00:00
|
|
|
use PhpId3\Id3TagsReader;
|
2017-11-20 23:44:25 +00:00
|
|
|
|
2021-12-02 23:02:31 +00:00
|
|
|
class Mp3audio
|
|
|
|
{
|
2017-11-20 23:44:25 +00:00
|
|
|
|
2021-12-02 23:02:31 +00:00
|
|
|
public function Match($type)
|
|
|
|
{
|
|
|
|
return (($type === 'audio/mpeg') ? true : false);
|
|
|
|
}
|
2017-11-20 23:44:25 +00:00
|
|
|
|
2021-12-02 23:02:31 +00:00
|
|
|
public function Thumb($attach, $preview_style, $height = 300, $width = 300)
|
|
|
|
{
|
2017-11-20 23:44:25 +00:00
|
|
|
|
2021-12-02 23:02:31 +00:00
|
|
|
$fh = @fopen(dbunescbin($attach['content']), 'rb');
|
|
|
|
if ($fh === false) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$id3 = new Id3TagsReader($fh);
|
|
|
|
$id3->readAllTags();
|
2017-11-20 23:44:25 +00:00
|
|
|
|
2021-12-02 23:02:31 +00:00
|
|
|
$image = $id3->getImage();
|
|
|
|
if (is_array($image)) {
|
|
|
|
$photo = $image[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose($fh);
|
2017-11-20 23:44:25 +00:00
|
|
|
|
2019-07-08 06:35:24 +00:00
|
|
|
if ($photo) {
|
2021-12-02 23:02:31 +00:00
|
|
|
$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);
|
2017-11-20 23:44:25 +00:00
|
|
|
imagedestroy($image);
|
2021-12-02 23:02:31 +00:00
|
|
|
imagejpeg($dest, dbunescbin($attach['content']) . '.thumb');
|
|
|
|
}
|
|
|
|
}
|
2017-11-20 23:44:25 +00:00
|
|
|
}
|