perf: 优化缩略图
This commit is contained in:
@@ -2507,7 +2507,7 @@ class Base
|
||||
*/
|
||||
public static function isThumb($file): bool
|
||||
{
|
||||
return preg_match('/_thumb\.(jpg|jpeg|png)$/', $file);
|
||||
return preg_match('/_thumb\.(png|jpg|jpeg)$/', $file);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2535,7 +2535,8 @@ class Base
|
||||
*/
|
||||
public static function thumbRestore($file): string
|
||||
{
|
||||
return preg_replace('/_thumb\.(jpg|jpeg|png)$/', '', $file);
|
||||
$file = preg_replace('/_thumb\.(png|jpg|jpeg)$/', '', $file);
|
||||
return preg_replace('/\/crop\/([^\/]+)$/', '', $file);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,11 +58,11 @@ class Image
|
||||
|
||||
/**
|
||||
* 按比例裁剪
|
||||
* @param int $ratio
|
||||
* @param float $ratio
|
||||
* @return $this
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public function ratioCrop(int $ratio = 0): static
|
||||
public function ratioCrop(float $ratio = 0): static
|
||||
{
|
||||
if ($ratio === 0) {
|
||||
return $this;
|
||||
@@ -77,7 +77,7 @@ class Image
|
||||
$newHeight = $height;
|
||||
} elseif ($height > $width * $ratio) {
|
||||
$newWidth = $width;
|
||||
$newHeight = $width * 3;
|
||||
$newHeight = $width * $ratio;
|
||||
} else {
|
||||
return $this;
|
||||
}
|
||||
@@ -201,6 +201,15 @@ class Image
|
||||
$this->image->destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 销毁对象
|
||||
* @return void
|
||||
*/
|
||||
public function destroy()
|
||||
{
|
||||
$this->image->destroy();
|
||||
}
|
||||
|
||||
/** ******************************************************************************/
|
||||
/** ******************************************************************************/
|
||||
/** ******************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user