fixed for -- Unsupported image type image/vnd.microsoft.icon. GD driver is only able to decode JPG, PNG, GIF, BMP or WebP files.
This commit is contained in:
parent
8e16e3a484
commit
3aa42e8055
|
|
@ -12,6 +12,7 @@
|
||||||
namespace Beike\Services;
|
namespace Beike\Services;
|
||||||
|
|
||||||
use Intervention\Image\Facades\Image;
|
use Intervention\Image\Facades\Image;
|
||||||
|
use Intervention\Image\Exception\NotReadableException;
|
||||||
|
|
||||||
class ImageService
|
class ImageService
|
||||||
{
|
{
|
||||||
|
|
@ -43,6 +44,7 @@ class ImageService
|
||||||
*/
|
*/
|
||||||
public function resize(int $width = 100, int $height = 100): string
|
public function resize(int $width = 100, int $height = 100): string
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
$extension = pathinfo($this->imagePath, PATHINFO_EXTENSION);
|
$extension = pathinfo($this->imagePath, PATHINFO_EXTENSION);
|
||||||
$newImage = 'cache/' . mb_substr($this->image, 0, mb_strrpos($this->image, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
|
$newImage = 'cache/' . mb_substr($this->image, 0, mb_strrpos($this->image, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
|
||||||
|
|
||||||
|
|
@ -60,6 +62,9 @@ class ImageService
|
||||||
$canvas->save($newImagePath);
|
$canvas->save($newImagePath);
|
||||||
}
|
}
|
||||||
return asset($newImage);
|
return asset($newImage);
|
||||||
|
} catch (NotReadableException $e) {
|
||||||
|
return $this->originUrl();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue