mirror of
https://github.com/lsky-org/lsky-pro.git
synced 2025-01-05 10:27:39 +08:00
feat: 添加svg矢量图的支持 (#833)
This commit is contained in:
parent
66d7a0dce1
commit
fe5e4d9a67
@ -165,7 +165,7 @@ class Controller extends BaseController
|
||||
if (
|
||||
$image->group?->configs->get(GroupConfigKey::IsEnableWatermark) &&
|
||||
$configs->get('mode', Mode::Overlay) == Mode::Dynamic &&
|
||||
! in_array($image->extension, ['ico', 'gif'])
|
||||
! in_array($image->extension, ['ico', 'gif', 'svg'])
|
||||
) {
|
||||
$contents = $service->stickWatermark($contents, $configs)->encode()->getEncoded();
|
||||
}
|
||||
@ -184,8 +184,8 @@ class Controller extends BaseController
|
||||
|
||||
$mimetype = $image->mimetype;
|
||||
|
||||
// ico 图片直接输出,不经过 InterventionImage 处理
|
||||
if ($image->extension === 'ico') {
|
||||
// ico svg 图片直接输出,不经过 InterventionImage 处理
|
||||
if (in_array($image->extension, ['ico', 'svg'])) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ class GroupRequest extends FormRequest
|
||||
'configs.image_save_format' => '',
|
||||
'configs.path_naming_rule' => 'max:400',
|
||||
'configs.file_naming_rule' => 'max:400',
|
||||
'configs.accepted_file_suffixes' => 'required|array|in:jpeg,jpg,png,gif,tif,bmp,ico,psd,webp',
|
||||
'configs.accepted_file_suffixes' => 'required|array|in:jpeg,jpg,png,gif,tif,bmp,ico,psd,webp,svg',
|
||||
|
||||
'configs.is_enable_scan' => 'boolean',
|
||||
'configs.scanned_action' => [
|
||||
|
@ -151,8 +151,8 @@ class ImageService
|
||||
// 上传频率限制
|
||||
$this->rateLimiter($configs, $request);
|
||||
|
||||
// 图片处理,跳过 ico 于 gif
|
||||
if (! in_array($extension, ['ico', 'gif'])) {
|
||||
// 图片处理,跳过 ico gif svg
|
||||
if (! in_array($extension, ['ico', 'gif', 'svg'])) {
|
||||
// 图片保存质量与格式
|
||||
$quality = $configs->get(GroupConfigKey::ImageSaveQuality, 75);
|
||||
$format = $configs->get(GroupConfigKey::ImageSaveFormat);
|
||||
@ -245,8 +245,8 @@ class ImageService
|
||||
throw new UploadException('图片记录保存失败');
|
||||
}
|
||||
|
||||
// 图片检测,跳过 tif、ico 以及 psd 格式
|
||||
if ($configs->get(GroupConfigKey::IsEnableScan) && ! in_array($extension, ['psd', 'ico', 'tif'])) {
|
||||
// 图片检测,跳过 tif、ico、psd、svg 格式
|
||||
if ($configs->get(GroupConfigKey::IsEnableScan) && ! in_array($extension, ['psd', 'ico', 'tif', 'svg'])) {
|
||||
$scanConfigs = $configs->get(GroupConfigKey::ScanConfigs);
|
||||
if ($this->scan(
|
||||
driver: $scanConfigs['driver'],
|
||||
@ -266,8 +266,10 @@ class ImageService
|
||||
}
|
||||
}
|
||||
|
||||
// 生成缩略图
|
||||
$this->makeThumbnail($image, $file);
|
||||
// 生成缩略图,svg等格式本身体积足够小且网页原生支持(比生成的png缩略图还小),不用生成缩略图
|
||||
if(!in_array($extension, ['svg'])) {
|
||||
$this->makeThumbnail($image, $file);
|
||||
}
|
||||
|
||||
return $image;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ return [
|
||||
GroupConfigKey::LimitPerDay => 300,
|
||||
GroupConfigKey::LimitPerWeek => 600,
|
||||
GroupConfigKey::LimitPerMonth => 999,
|
||||
GroupConfigKey::AcceptedFileSuffixes => ['jpeg', 'jpg', 'png', 'gif', 'tif', 'bmp', 'ico', 'psd', 'webp'],
|
||||
GroupConfigKey::AcceptedFileSuffixes => ['jpeg', 'jpg', 'png', 'gif', 'tif', 'bmp', 'ico', 'psd', 'webp', 'svg'],
|
||||
GroupConfigKey::ImageSaveFormat => '',
|
||||
GroupConfigKey::ImageSaveQuality => 75,
|
||||
GroupConfigKey::PathNamingRule => '{Y}/{m}/{d}',
|
||||
|
Loading…
Reference in New Issue
Block a user