mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-21 20:48:00 +01:00
Added a checks to buildCovers and processFile
This commit is contained in:
parent
d96fde1f55
commit
72117b000c
1 changed files with 12 additions and 2 deletions
|
@ -23,6 +23,7 @@ namespace Poniverse\Ponyfm\Models;
|
|||
use External;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Config;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
|
@ -136,8 +137,12 @@ class Image extends Model
|
|||
* @param array $coverType The type to process the image to
|
||||
*/
|
||||
private static function processFile(File $image, string $path, $coverType) {
|
||||
if ($coverType['id'] === self::ORIGINAL && $image->getMimeType() === self::MIME_JPEG) {
|
||||
$command = 'cp "'.$image->getPathname().'" '.$path;
|
||||
if ($coverType['id'] === self::ORIGINAL && $image->getMimeType() === self::MIME_JPEG ){
|
||||
if($image->getPathname() === $path) {
|
||||
Log::warning("Attempted to copy an original file $path to itself.");
|
||||
} else {
|
||||
$command = 'cp "' . $image->getPathname() . '" ' . $path;
|
||||
}
|
||||
} else {
|
||||
// ImageMagick options reference: http://www.imagemagick.org/script/command-line-options.php
|
||||
$command = 'convert 2>&1 "'.$image->getPathname().'" -background white -alpha remove -alpha off -strip';
|
||||
|
@ -229,6 +234,11 @@ class Image extends Model
|
|||
$originalFile = new File($this->getFile(self::ORIGINAL));
|
||||
|
||||
foreach (self::$ImageTypes as $imageType) {
|
||||
//Ignore original imagetype
|
||||
if($imageType['id'] === self::ORIGINAL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
self::processFile($originalFile, $this->getFile($imageType['id']), $imageType);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue