perf: 优化缩略图

This commit is contained in:
kuaifan
2024-10-29 21:06:08 +08:00
parent 50a7950ccd
commit d799c06017
7 changed files with 257 additions and 33 deletions

View 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();
}
/** ******************************************************************************/
/** ******************************************************************************/
/** ******************************************************************************/