diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index ee3eab5..bf7bcda 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -41,9 +41,6 @@ jobs: sudo apt-get install -y jpegoptim pngquant gifsicle optipng libjpeg-progs webp sudo npm install -g svgo - - name: Install librsvg - run: sudo apt-get install -y librsvg2-2 librsvg2-bin - - name: Setup PHP uses: shivammathur/setup-php@v2 with: diff --git a/src/Storage/Image.php b/src/Storage/Image.php index fafc949..7571f7b 100755 --- a/src/Storage/Image.php +++ b/src/Storage/Image.php @@ -75,9 +75,12 @@ public function resize(string $saveTo, ImageStyle $style): bool $this->resizeAuto($style->width, $style->height); } + $isSvg = $this->file->getExtension() === 'svg'; if ($this->driverIsLocal) { - $this->image->encode()->save($saveTo); + $isSvg + ? $this->image->toPng()->save($saveTo) + : $this->image->encode()->save($saveTo); } else { list($path, $name) = split_larupload_path($saveTo); @@ -86,7 +89,9 @@ public function resize(string $saveTo, ImageStyle $style): bool $tempName = time() . '-' . $name; $temp = "$tempDir/$tempName"; - $this->image->encode()->save($temp); + $isSvg + ? $this->image->toPng()->save($temp) + : $this->image->encode()->save($temp); Storage::disk($this->disk)->putFileAs($path, new File($temp), $name);