for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Spatie\MediaLibrary\ImageGenerators\FileTypes;
use Illuminate\Support\Collection;
use Imagick;
use ImagickPixel;
use Spatie\MediaLibrary\Conversion\Conversion;
use Spatie\MediaLibrary\ImageGenerators\BaseGenerator;
class Svg extends BaseGenerator
{
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');
public function supportedExtensions(): Collection
return collect('svg');
public function supportedMimeTypes(): Collection
return collect('image/svg+xml');