File "Svg.php"
Full Path: /home/clickysoft/public_html/jmapi5.clickysoft.net/vendor/spatie/laravel-medialibrary/src/Conversions/ImageGenerators/Svg.php
File size: 979 bytes
MIME-type: text/x-php
Charset: utf-8
<?php
namespace Spatie\MediaLibrary\Conversions\ImageGenerators;
use Illuminate\Support\Collection;
use Imagick;
use ImagickPixel;
use Spatie\MediaLibrary\Conversions\Conversion;
class Svg extends ImageGenerator
{
public function convert(string $file, Conversion $conversion = null): string
{
$imageFile = pathinfo($file, PATHINFO_DIRNAME).'/'.pathinfo($file, PATHINFO_FILENAME).'.jpg';
$image = new Imagick();
$image->readImage($file);
$image->setBackgroundColor(new ImagickPixel('none'));
$image->setImageFormat('jpg');
file_put_contents($imageFile, $image);
return $imageFile;
}
public function requirementsAreInstalled(): bool
{
return class_exists(\Imagick::class);
}
public function supportedExtensions(): Collection
{
return collect(['svg']);
}
public function supportedMimeTypes(): Collection
{
return collect(['image/svg+xml']);
}
}