Skip to content

Commit

Permalink
Fix SVG files loosing transparency during conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasbeauvais committed Nov 21, 2024
1 parent 2e6aa4f commit cf323d6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Conversions/ImageGenerators/Svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ class Svg extends ImageGenerator
{
public function convert(string $file, ?Conversion $conversion = null): string
{
$imageFile = pathinfo($file, PATHINFO_DIRNAME).'/'.pathinfo($file, PATHINFO_FILENAME).'.jpg';
$imageFile = pathinfo($file, PATHINFO_DIRNAME).'/'.pathinfo($file, PATHINFO_FILENAME).'.png';

$image = new Imagick;
$image->readImage($file);
$image = new Imagick();
$image->setBackgroundColor(new ImagickPixel('none'));
$image->setImageFormat('jpg');
$image->readImage($file);

$image->setImageFormat('png32');

file_put_contents($imageFile, $image);

Expand Down

0 comments on commit cf323d6

Please sign in to comment.