|
|
@@ -6727,15 +6727,72 @@ class AnimeService
|
|
|
'script_id' => $script_id,
|
|
|
'script_name' => $script_name
|
|
|
]);
|
|
|
+
|
|
|
+ // 处理图片模型
|
|
|
+ $model = getProp($data, 'model');
|
|
|
+ if (!$model) {
|
|
|
+ // 使用默认模型
|
|
|
+ $model = 'doubao-seedream-5-0-lite-260128';
|
|
|
+ }
|
|
|
+ // 验证模型是否在可用模型表中
|
|
|
+ if (!DB::table('mp_image_models')->where('model', $model)->where('is_enabled', 1)->exists()) {
|
|
|
+ Utils::throwError('20003:该模型已不可用,请更换!');
|
|
|
+ }
|
|
|
+ $ratio = getProp($data, 'ratio', '16:9');
|
|
|
+ $resolution = getProp($data, 'resolution', '2k');
|
|
|
+
|
|
|
+ // 定义分辨率和宽高比对应的尺寸映射表
|
|
|
+ $sizeMap = [
|
|
|
+ '2k' => [
|
|
|
+ '1:1' => ['width' => 2048, 'height' => 2048],
|
|
|
+ '4:3' => ['width' => 2304, 'height' => 1728],
|
|
|
+ '3:4' => ['width' => 1728, 'height' => 2304],
|
|
|
+ '16:9' => ['width' => 2848, 'height' => 1600],
|
|
|
+ '9:16' => ['width' => 1600, 'height' => 2848],
|
|
|
+ '3:2' => ['width' => 2496, 'height' => 1664],
|
|
|
+ '2:3' => ['width' => 1664, 'height' => 2496],
|
|
|
+ '21:9' => ['width' => 3136, 'height' => 1344],
|
|
|
+ ],
|
|
|
+ '3k' => [
|
|
|
+ '1:1' => ['width' => 3072, 'height' => 3072],
|
|
|
+ '4:3' => ['width' => 3456, 'height' => 2592],
|
|
|
+ '3:4' => ['width' => 2592, 'height' => 3456],
|
|
|
+ '16:9' => ['width' => 4096, 'height' => 2304],
|
|
|
+ '9:16' => ['width' => 2304, 'height' => 4096],
|
|
|
+ '2:3' => ['width' => 2496, 'height' => 3744],
|
|
|
+ '3:2' => ['width' => 3744, 'height' => 2496],
|
|
|
+ '21:9' => ['width' => 4704, 'height' => 2016],
|
|
|
+ ],
|
|
|
+ '4k' => [
|
|
|
+ '1:1' => ['width' => 4096, 'height' => 4096],
|
|
|
+ '3:4' => ['width' => 3520, 'height' => 4704],
|
|
|
+ '4:3' => ['width' => 4704, 'height' => 3520],
|
|
|
+ '16:9' => ['width' => 5504, 'height' => 3040],
|
|
|
+ '9:16' => ['width' => 3040, 'height' => 5504],
|
|
|
+ '2:3' => ['width' => 3328, 'height' => 4992],
|
|
|
+ '3:2' => ['width' => 4992, 'height' => 3328],
|
|
|
+ '21:9' => ['width' => 6240, 'height' => 2656],
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+
|
|
|
+ // 参数验证
|
|
|
+ $resolution = strtolower($resolution);
|
|
|
+ if (!isset($sizeMap[$resolution])) {
|
|
|
+ Utils::throwError('20003:分辨率参数错误,仅支持 2k、3k、4k');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!isset($sizeMap[$resolution][$ratio])) {
|
|
|
+ Utils::throwError('20003:宽高比参数错误,该分辨率下不支持 ' . $ratio . ' 比例');
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据 ratio 和 resolution 确定宽高
|
|
|
+ $width = $sizeMap[$resolution][$ratio]['width'];
|
|
|
+ $height = $sizeMap[$resolution][$ratio]['height'];
|
|
|
|
|
|
// 开启事务
|
|
|
DB::beginTransaction();
|
|
|
|
|
|
try {
|
|
|
- // 默认图片生成参数
|
|
|
- $model = 'doubao-seedream-5-0-lite-260128';
|
|
|
- $width = 1600;
|
|
|
- $height = 2848;
|
|
|
|
|
|
foreach ($productsWithTasks as $product) {
|
|
|
// 跳过已有任务的资产
|