Format code using php-cs-fixer
This commit is contained in:
parent
43d7dc92cd
commit
d52c6184b9
352 changed files with 17473 additions and 17041 deletions
|
@ -1,78 +1,81 @@
|
|||
<?php
|
||||
|
||||
class FileDataHelper {
|
||||
|
||||
public static function getAudioMimeTypeArray() {
|
||||
return array(
|
||||
"audio/ogg" => "ogg",
|
||||
"application/ogg" => "ogg",
|
||||
"audio/vorbis" => "ogg",
|
||||
"audio/mp3" => "mp3",
|
||||
"audio/mpeg" => "mp3",
|
||||
"audio/mpeg3" => "mp3",
|
||||
"audio/x-aac" => "aac",
|
||||
"audio/aac" => "aac",
|
||||
"audio/aacp" => "aac",
|
||||
"audio/mp4" => "m4a",
|
||||
"video/mp4" => "mp4",
|
||||
"audio/x-flac" => "flac",
|
||||
"audio/flac" => "flac",
|
||||
"audio/wav" => "wav",
|
||||
"audio/x-wav" => "wav",
|
||||
"audio/mp2" => "mp2",
|
||||
"audio/mp1" => "mp1",
|
||||
"audio/x-ms-wma" => "wma",
|
||||
"audio/basic" => "au",
|
||||
);
|
||||
class FileDataHelper
|
||||
{
|
||||
public static function getAudioMimeTypeArray()
|
||||
{
|
||||
return [
|
||||
'audio/ogg' => 'ogg',
|
||||
'application/ogg' => 'ogg',
|
||||
'audio/vorbis' => 'ogg',
|
||||
'audio/mp3' => 'mp3',
|
||||
'audio/mpeg' => 'mp3',
|
||||
'audio/mpeg3' => 'mp3',
|
||||
'audio/x-aac' => 'aac',
|
||||
'audio/aac' => 'aac',
|
||||
'audio/aacp' => 'aac',
|
||||
'audio/mp4' => 'm4a',
|
||||
'video/mp4' => 'mp4',
|
||||
'audio/x-flac' => 'flac',
|
||||
'audio/flac' => 'flac',
|
||||
'audio/wav' => 'wav',
|
||||
'audio/x-wav' => 'wav',
|
||||
'audio/mp2' => 'mp2',
|
||||
'audio/mp1' => 'mp1',
|
||||
'audio/x-ms-wma' => 'wma',
|
||||
'audio/basic' => 'au',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* We want to throw out invalid data and process the upload successfully
|
||||
* at all costs, so check the data and sanitize it if necessary
|
||||
* at all costs, so check the data and sanitize it if necessary.
|
||||
*
|
||||
* @param array $data array containing new file metadata
|
||||
*/
|
||||
public static function sanitizeData(&$data)
|
||||
{
|
||||
if (array_key_exists("track_number", $data)) {
|
||||
if (array_key_exists('track_number', $data)) {
|
||||
// If the track number isn't numeric, this will return 0
|
||||
$data["track_number"] = intval($data["track_number"]);
|
||||
$data['track_number'] = intval($data['track_number']);
|
||||
}
|
||||
if (array_key_exists("year", $data)) {
|
||||
if (array_key_exists('year', $data)) {
|
||||
// If the track number isn't numeric, this will return 0
|
||||
$data["year"] = intval($data["year"]);
|
||||
$data['year'] = intval($data['year']);
|
||||
}
|
||||
if (array_key_exists("bpm", $data)) {
|
||||
if (array_key_exists('bpm', $data)) {
|
||||
//Some BPM tags are silly and include the word "BPM". Let's strip that...
|
||||
$data["bpm"] = str_ireplace("BPM", "", $data["bpm"]);
|
||||
$data['bpm'] = str_ireplace('BPM', '', $data['bpm']);
|
||||
// This will convert floats to ints too.
|
||||
$data["bpm"] = intval($data["bpm"]);
|
||||
$data['bpm'] = intval($data['bpm']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a suitable extension for the given file
|
||||
* Return a suitable extension for the given file.
|
||||
*
|
||||
* @param string $mime
|
||||
*
|
||||
* @return string file extension with(!) a dot (for convenience)
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return string file extension with(!) a dot (for convenience)
|
||||
*/
|
||||
public static function getFileExtensionFromMime($mime)
|
||||
{
|
||||
$mime = trim(strtolower($mime));
|
||||
|
||||
try {
|
||||
return ('.' . static::getAudioMimeTypeArray()[$mime]);
|
||||
return '.' . static::getAudioMimeTypeArray()[$mime];
|
||||
} catch (Exception $e) {
|
||||
throw new Exception("Unknown file type: $mime");
|
||||
throw new Exception("Unknown file type: {$mime}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets data URI from artwork file
|
||||
* Gets data URI from artwork file.
|
||||
*
|
||||
* @param string $file
|
||||
* @param int $size
|
||||
* @param int $size
|
||||
* @param string $filepath
|
||||
*
|
||||
* @return string Data URI for artwork
|
||||
|
@ -80,29 +83,30 @@ class FileDataHelper {
|
|||
public static function getArtworkData($file, $size, $filepath = false)
|
||||
{
|
||||
$baseUrl = Application_Common_HTTPHelper::getStationUrl();
|
||||
$default = $baseUrl . "css/images/no-cover.jpg";
|
||||
$default = $baseUrl . 'css/images/no-cover.jpg';
|
||||
|
||||
if ($filepath != false) {
|
||||
$path = $filepath . $file . "-" . $size;
|
||||
$path = $filepath . $file . '-' . $size;
|
||||
if (!file_exists($path)) {
|
||||
$get_file_content = $default;
|
||||
} else {
|
||||
$get_file_content = file_get_contents($path);
|
||||
$get_file_content = file_get_contents($path);
|
||||
}
|
||||
} else {
|
||||
$storDir = Application_Model_MusicDir::getStorDir();
|
||||
$path = $storDir->getDirectory() . $file . "-" . $size;
|
||||
$path = $storDir->getDirectory() . $file . '-' . $size;
|
||||
if (!file_exists($path)) {
|
||||
$get_file_content = $default;
|
||||
} else {
|
||||
$get_file_content = file_get_contents($path);
|
||||
$get_file_content = file_get_contents($path);
|
||||
}
|
||||
}
|
||||
|
||||
return $get_file_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add artwork file
|
||||
* Add artwork file.
|
||||
*
|
||||
* @param string $analyzeFile
|
||||
* @param string $filename
|
||||
|
@ -118,53 +122,53 @@ class FileDataHelper {
|
|||
$getFileInfo = $getID3->analyze($analyzeFile);
|
||||
} else {
|
||||
$getFileInfo = [];
|
||||
Logging::error("Failed to load getid3 library. Please upgrade Libretime.");
|
||||
Logging::error('Failed to load getid3 library. Please upgrade Libretime.');
|
||||
}
|
||||
|
||||
if(isset($getFileInfo['comments']['picture'][0])) {
|
||||
if (isset($getFileInfo['comments']['picture'][0])) {
|
||||
$get_img = '';
|
||||
$timestamp = time();
|
||||
$mime = $getFileInfo['comments']['picture'][0]['image_mime'];
|
||||
$Image = 'data:' . $mime . ';charset=utf-8;base64,' . base64_encode($getFileInfo['comments']['picture'][0]['data']);
|
||||
$base64 = @$Image;
|
||||
|
||||
$get_img = "";
|
||||
$timestamp = time();
|
||||
$mime = $getFileInfo['comments']['picture'][0]['image_mime'];
|
||||
$Image = 'data:'.$mime.';charset=utf-8;base64,'.base64_encode($getFileInfo['comments']['picture'][0]['data']);
|
||||
$base64 = @$Image;
|
||||
if (!file_exists($importDir . '/' . 'artwork/')) {
|
||||
if (!mkdir($importDir . '/' . 'artwork/', 0777, true)) {
|
||||
Logging::error('Failed to create artwork directory.');
|
||||
|
||||
if (!file_exists($importDir . "/" . "artwork/")) {
|
||||
if (!mkdir($importDir . "/" . "artwork/", 0777, true)) {
|
||||
Logging::error("Failed to create artwork directory.");
|
||||
throw new Exception("Failed to create artwork directory.");
|
||||
}
|
||||
}
|
||||
throw new Exception('Failed to create artwork directory.');
|
||||
}
|
||||
}
|
||||
|
||||
$path_parts = pathinfo($filename);
|
||||
$file = $importDir . "artwork/" . $path_parts['filename'];
|
||||
$path_parts = pathinfo($filename);
|
||||
$file = $importDir . 'artwork/' . $path_parts['filename'];
|
||||
|
||||
//Save Data URI
|
||||
if (file_put_contents($file, $base64)) {
|
||||
$get_img = $DbPath . "artwork/". $path_parts['filename'];
|
||||
} else {
|
||||
Logging::error("Could not save Data URI");
|
||||
}
|
||||
|
||||
if ($mime == "image/png") {
|
||||
$ext = 'png';
|
||||
} elseif ($mime == "image/gif") {
|
||||
$ext = 'gif';
|
||||
} elseif ($mime == "image/bmp") {
|
||||
$ext = 'bmp';
|
||||
} else {
|
||||
$ext = 'jpg';
|
||||
}
|
||||
self::resizeGroup($file, $ext);
|
||||
//Save Data URI
|
||||
if (file_put_contents($file, $base64)) {
|
||||
$get_img = $DbPath . 'artwork/' . $path_parts['filename'];
|
||||
} else {
|
||||
Logging::error('Could not save Data URI');
|
||||
}
|
||||
|
||||
if ($mime == 'image/png') {
|
||||
$ext = 'png';
|
||||
} elseif ($mime == 'image/gif') {
|
||||
$ext = 'gif';
|
||||
} elseif ($mime == 'image/bmp') {
|
||||
$ext = 'bmp';
|
||||
} else {
|
||||
$ext = 'jpg';
|
||||
}
|
||||
self::resizeGroup($file, $ext);
|
||||
} else {
|
||||
$get_img = '';
|
||||
$get_img = '';
|
||||
}
|
||||
|
||||
return $get_img;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset artwork
|
||||
* Reset artwork.
|
||||
*
|
||||
* @param string $trackid
|
||||
*
|
||||
|
@ -178,7 +182,7 @@ class FileDataHelper {
|
|||
$storDir = Application_Model_MusicDir::getStorDir();
|
||||
$fp = $storDir->getDirectory();
|
||||
|
||||
$dbAudioPath = $md["MDATA_KEY_FILEPATH"];
|
||||
$dbAudioPath = $md['MDATA_KEY_FILEPATH'];
|
||||
$fullpath = $fp . $dbAudioPath;
|
||||
|
||||
if (class_exists('getID3')) {
|
||||
|
@ -186,49 +190,48 @@ class FileDataHelper {
|
|||
$getFileInfo = $getID3->analyze($fullpath);
|
||||
} else {
|
||||
$getFileInfo = [];
|
||||
Logging::error("Failed to load getid3 library. Please upgrade Libretime.");
|
||||
Logging::error('Failed to load getid3 library. Please upgrade Libretime.');
|
||||
}
|
||||
|
||||
if(isset($getFileInfo['comments']['picture'][0])) {
|
||||
if (isset($getFileInfo['comments']['picture'][0])) {
|
||||
$get_img = '';
|
||||
$mime = $getFileInfo['comments']['picture'][0]['image_mime'];
|
||||
$Image = 'data:' . $getFileInfo['comments']['picture'][0]['image_mime'] . ';charset=utf-8;base64,' . base64_encode($getFileInfo['comments']['picture'][0]['data']);
|
||||
$base64 = @$Image;
|
||||
|
||||
$get_img = "";
|
||||
$mime = $getFileInfo['comments']['picture'][0]['image_mime'];
|
||||
$Image = 'data:'.$getFileInfo['comments']['picture'][0]['image_mime'].';charset=utf-8;base64,'.base64_encode($getFileInfo['comments']['picture'][0]['data']);
|
||||
$base64 = @$Image;
|
||||
$audioPath = dirname($fullpath);
|
||||
$dbPath = dirname($dbAudioPath);
|
||||
$path_parts = pathinfo($fullpath);
|
||||
$file = $path_parts['filename'];
|
||||
|
||||
$audioPath = dirname($fullpath);
|
||||
$dbPath = dirname($dbAudioPath);
|
||||
$path_parts = pathinfo($fullpath);
|
||||
$file = $path_parts['filename'];
|
||||
//Save Data URI
|
||||
if (file_put_contents($audioPath . '/' . $file, $base64)) {
|
||||
$get_img = $dbPath . '/' . $file;
|
||||
} else {
|
||||
Logging::error('Could not save Data URI');
|
||||
}
|
||||
|
||||
//Save Data URI
|
||||
if (file_put_contents($audioPath . "/" . $file, $base64)) {
|
||||
$get_img = $dbPath . "/" . $file;
|
||||
} else {
|
||||
Logging::error("Could not save Data URI");
|
||||
}
|
||||
|
||||
$rfile = $audioPath . "/" . $file;
|
||||
|
||||
if ($mime == "image/png") {
|
||||
$ext = 'png';
|
||||
} elseif ($mime == "image/gif") {
|
||||
$ext = 'gif';
|
||||
} elseif ($mime == "image/bmp") {
|
||||
$ext = 'bmp';
|
||||
} else {
|
||||
$ext = 'jpg';
|
||||
}
|
||||
self::resizeGroup($rfile, $ext);
|
||||
$rfile = $audioPath . '/' . $file;
|
||||
|
||||
if ($mime == 'image/png') {
|
||||
$ext = 'png';
|
||||
} elseif ($mime == 'image/gif') {
|
||||
$ext = 'gif';
|
||||
} elseif ($mime == 'image/bmp') {
|
||||
$ext = 'bmp';
|
||||
} else {
|
||||
$ext = 'jpg';
|
||||
}
|
||||
self::resizeGroup($rfile, $ext);
|
||||
} else {
|
||||
$get_img = "";
|
||||
$get_img = '';
|
||||
}
|
||||
|
||||
return $get_img;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload artwork
|
||||
* Upload artwork.
|
||||
*
|
||||
* @param string $trackid
|
||||
* @param string $data
|
||||
|
@ -243,16 +246,13 @@ class FileDataHelper {
|
|||
$storDir = Application_Model_MusicDir::getStorDir();
|
||||
$fp = $storDir->getDirectory();
|
||||
|
||||
$dbAudioPath = $md["MDATA_KEY_FILEPATH"];
|
||||
$dbAudioPath = $md['MDATA_KEY_FILEPATH'];
|
||||
$fullpath = $fp . $dbAudioPath;
|
||||
|
||||
if ($data == "0") {
|
||||
|
||||
$get_img = "";
|
||||
if ($data == '0') {
|
||||
$get_img = '';
|
||||
self::removeArtwork($trackid, $data);
|
||||
|
||||
} else {
|
||||
|
||||
$base64 = @$data;
|
||||
$mime = explode(';', $base64)[0];
|
||||
|
||||
|
@ -262,32 +262,33 @@ class FileDataHelper {
|
|||
$file = $path_parts['filename'];
|
||||
|
||||
//Save Data URI
|
||||
if (file_put_contents($audioPath . "/" . $file, $base64)) {
|
||||
$get_img = $dbPath . "/" . $file;
|
||||
if (file_put_contents($audioPath . '/' . $file, $base64)) {
|
||||
$get_img = $dbPath . '/' . $file;
|
||||
} else {
|
||||
Logging::error("Could not save Data URI");
|
||||
Logging::error('Could not save Data URI');
|
||||
}
|
||||
|
||||
$rfile = $audioPath . "/" . $file;
|
||||
$rfile = $audioPath . '/' . $file;
|
||||
|
||||
if ($mime == "data:image/png") {
|
||||
if ($mime == 'data:image/png') {
|
||||
$ext = 'png';
|
||||
} elseif ($mime == "data:image/gif") {
|
||||
} elseif ($mime == 'data:image/gif') {
|
||||
$ext = 'gif';
|
||||
} elseif ($mime == "data:image/bmp") {
|
||||
$ext = 'bmp';
|
||||
} elseif ($mime == 'data:image/bmp') {
|
||||
$ext = 'bmp';
|
||||
} else {
|
||||
$ext = 'jpg';
|
||||
$ext = 'jpg';
|
||||
}
|
||||
self::resizeGroup($rfile, $ext);
|
||||
|
||||
}
|
||||
|
||||
return $get_img;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes just the artwork.
|
||||
*
|
||||
* Deletes just the artwork
|
||||
* @param mixed $trackid
|
||||
*/
|
||||
public static function removeArtwork($trackid)
|
||||
{
|
||||
|
@ -297,144 +298,143 @@ class FileDataHelper {
|
|||
$storDir = Application_Model_MusicDir::getStorDir();
|
||||
$fp = $storDir->getDirectory();
|
||||
|
||||
$dbAudioPath = $md["MDATA_KEY_ARTWORK"];
|
||||
$dbAudioPath = $md['MDATA_KEY_ARTWORK'];
|
||||
$fullpath = $fp . $dbAudioPath;
|
||||
|
||||
if (file_exists($fullpath)) {
|
||||
foreach (glob("$fullpath*", GLOB_NOSORT) as $filename) {
|
||||
foreach (glob("{$fullpath}*", GLOB_NOSORT) as $filename) {
|
||||
unlink($filename);
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Could not locate file ".$filepath);
|
||||
throw new Exception('Could not locate file ' . $filepath);
|
||||
}
|
||||
return "";
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize artwork group
|
||||
* Resize artwork group.
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $ext
|
||||
*/
|
||||
public static function resizeGroup($file, $ext)
|
||||
{
|
||||
if (file_exists($file)) {
|
||||
self::resizeImage($file, $file . '-32.jpg', $ext, 32, 100);
|
||||
self::resizeImage($file, $file . '-64.jpg', $ext, 64, 100);
|
||||
self::resizeImage($file, $file . '-128.jpg', $ext, 128, 100);
|
||||
self::resizeImage($file, $file . '-256.jpg', $ext, 256, 100);
|
||||
self::resizeImage($file, $file . '-512.jpg', $ext, 512, 100);
|
||||
self::imgToDataURI($file . '-32.jpg', $file . '-32');
|
||||
self::imgToDataURI($file . '-64.jpg', $file . '-64');
|
||||
self::imgToDataURI($file . '-128.jpg', $file . '-128');
|
||||
self::imgToDataURI($file . '-256.jpg', $file . '-256');
|
||||
} else {
|
||||
Logging::error("The file $file does not exist");
|
||||
}
|
||||
if (file_exists($file)) {
|
||||
self::resizeImage($file, $file . '-32.jpg', $ext, 32, 100);
|
||||
self::resizeImage($file, $file . '-64.jpg', $ext, 64, 100);
|
||||
self::resizeImage($file, $file . '-128.jpg', $ext, 128, 100);
|
||||
self::resizeImage($file, $file . '-256.jpg', $ext, 256, 100);
|
||||
self::resizeImage($file, $file . '-512.jpg', $ext, 512, 100);
|
||||
self::imgToDataURI($file . '-32.jpg', $file . '-32');
|
||||
self::imgToDataURI($file . '-64.jpg', $file . '-64');
|
||||
self::imgToDataURI($file . '-128.jpg', $file . '-128');
|
||||
self::imgToDataURI($file . '-256.jpg', $file . '-256');
|
||||
} else {
|
||||
Logging::error("The file {$file} does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render image
|
||||
* Used in API to render JPEG
|
||||
* Used in API to render JPEG.
|
||||
*
|
||||
* @param string $file
|
||||
*/
|
||||
public static function renderImage($file)
|
||||
{
|
||||
$im = @imagecreatefromjpeg($file);
|
||||
header('Content-Type: image/jpeg');
|
||||
$img = $im;
|
||||
imagejpeg($img);
|
||||
imagedestroy($img);
|
||||
$im = @imagecreatefromjpeg($file);
|
||||
header('Content-Type: image/jpeg');
|
||||
$img = $im;
|
||||
imagejpeg($img);
|
||||
imagedestroy($img);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render Data URI
|
||||
* Used in API to render Data URI
|
||||
* Used in API to render Data URI.
|
||||
*
|
||||
* @param string $dataFile
|
||||
*/
|
||||
public static function renderDataURI($dataFile)
|
||||
{
|
||||
if($filecontent = file_get_contents($dataFile) !== false){
|
||||
$image = @file_get_contents($dataFile);
|
||||
$image = base64_encode($image);
|
||||
if (!$image || $image === '') {
|
||||
return;
|
||||
}
|
||||
$blob = base64_decode($image);
|
||||
$f = finfo_open();
|
||||
$mime_type = finfo_buffer($f, $blob, FILEINFO_MIME_TYPE);
|
||||
finfo_close($f);
|
||||
header("Content-Type: " . $mime_type);
|
||||
echo $blob;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if ($filecontent = file_get_contents($dataFile) !== false) {
|
||||
$image = @file_get_contents($dataFile);
|
||||
$image = base64_encode($image);
|
||||
if (!$image || $image === '') {
|
||||
return;
|
||||
}
|
||||
$blob = base64_decode($image);
|
||||
$f = finfo_open();
|
||||
$mime_type = finfo_buffer($f, $blob, FILEINFO_MIME_TYPE);
|
||||
finfo_close($f);
|
||||
header('Content-Type: ' . $mime_type);
|
||||
echo $blob;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize Image
|
||||
* Resize Image.
|
||||
*
|
||||
* @param string $orig_filename
|
||||
* @param string $converted_filename
|
||||
* @param string $ext
|
||||
* @param string $size Default: 500
|
||||
* @param string $quality Default: 75
|
||||
*
|
||||
* @param string $size Default: 500
|
||||
* @param string $quality Default: 75
|
||||
*/
|
||||
public static function resizeImage($orig_filename, $converted_filename, $ext, $size=500, $quality=75)
|
||||
public static function resizeImage($orig_filename, $converted_filename, $ext, $size = 500, $quality = 75)
|
||||
{
|
||||
$get_cont = file_get_contents($orig_filename);
|
||||
if ($ext == "png") {
|
||||
$im = @imagecreatefrompng($get_cont);
|
||||
} elseif ($ext == "gif") {
|
||||
$im = @imagecreatefromgif($get_cont);
|
||||
} else {
|
||||
$im = @imagecreatefromjpeg($get_cont);
|
||||
}
|
||||
$get_cont = file_get_contents($orig_filename);
|
||||
if ($ext == 'png') {
|
||||
$im = @imagecreatefrompng($get_cont);
|
||||
} elseif ($ext == 'gif') {
|
||||
$im = @imagecreatefromgif($get_cont);
|
||||
} else {
|
||||
$im = @imagecreatefromjpeg($get_cont);
|
||||
}
|
||||
|
||||
// if one of those bombs, create an error image instead
|
||||
if (!$im) {
|
||||
$im = imagecreatetruecolor(150, 30);
|
||||
$bgc = imagecolorallocate($im, 255, 255, 255);
|
||||
$tc = imagecolorallocate($im, 0, 0, 0);
|
||||
imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
|
||||
imagestring($im, 1, 5, 5, 'Error loading ' . $converted_filename, $tc);
|
||||
}
|
||||
|
||||
// scale if appropriate
|
||||
if ($size){
|
||||
$im = imagescale($im , $size);
|
||||
}
|
||||
// if one of those bombs, create an error image instead
|
||||
if (!$im) {
|
||||
$im = imagecreatetruecolor(150, 30);
|
||||
$bgc = imagecolorallocate($im, 255, 255, 255);
|
||||
$tc = imagecolorallocate($im, 0, 0, 0);
|
||||
imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
|
||||
imagestring($im, 1, 5, 5, 'Error loading ' . $converted_filename, $tc);
|
||||
}
|
||||
|
||||
$img = $im;
|
||||
imagejpeg($img, $converted_filename, $quality);
|
||||
imagedestroy($img);
|
||||
// scale if appropriate
|
||||
if ($size) {
|
||||
$im = imagescale($im, $size);
|
||||
}
|
||||
|
||||
$img = $im;
|
||||
imagejpeg($img, $converted_filename, $quality);
|
||||
imagedestroy($img);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert image to Data URI
|
||||
* Convert image to Data URI.
|
||||
*
|
||||
* @param string $orig_filename
|
||||
* @param string $conv_filename
|
||||
*/
|
||||
public static function imgToDataURI($orig_filename, $conv_filename)
|
||||
{
|
||||
$file = file_get_contents($orig_filename);
|
||||
$Image = 'data:image/jpeg;charset=utf-8;base64,'.base64_encode($file);
|
||||
$base64 = @$Image;
|
||||
$file = file_get_contents($orig_filename);
|
||||
$Image = 'data:image/jpeg;charset=utf-8;base64,' . base64_encode($file);
|
||||
$base64 = @$Image;
|
||||
|
||||
//Save Data URI
|
||||
if (file_put_contents($conv_filename, $base64)) {
|
||||
|
||||
} else {
|
||||
Logging::error("Could not save Data URI");
|
||||
}
|
||||
//Save Data URI
|
||||
if (file_put_contents($conv_filename, $base64)) {
|
||||
} else {
|
||||
Logging::error('Could not save Data URI');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Track Type
|
||||
* Track Type.
|
||||
*
|
||||
* @return string Track type key value
|
||||
*/
|
||||
|
@ -443,10 +443,10 @@ class FileDataHelper {
|
|||
if (isset($_COOKIE['tt_upload'])) {
|
||||
$tt = $_COOKIE['tt_upload'];
|
||||
} else {
|
||||
// Use default track type
|
||||
$tt = Application_Model_Preference::GetTrackTypeDefault();
|
||||
// Use default track type
|
||||
$tt = Application_Model_Preference::GetTrackTypeDefault();
|
||||
}
|
||||
|
||||
return $tt;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue