Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafaznv committed Dec 19, 2023
1 parent 4244f58 commit 42c71d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 7 additions & 2 deletions src/Storage/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down

0 comments on commit 42c71d5

Please sign in to comment.