修复视频生成时宽高的转换函数
This commit is contained in:
parent
44c7309608
commit
5e4fc0a1d1
|
|
@ -1,5 +1,41 @@
|
|||
import { fetchModelConfig } from '@/utils/modelConfig'
|
||||
|
||||
function getWidthHeight({ proportion, resolution }) {
|
||||
let baseSize
|
||||
switch (resolution) {
|
||||
case '1k':
|
||||
baseSize = 1024
|
||||
break
|
||||
case '2k':
|
||||
baseSize = 2048
|
||||
break
|
||||
case '4k':
|
||||
baseSize = 4096
|
||||
break
|
||||
default:
|
||||
baseSize = 2048
|
||||
}
|
||||
|
||||
if (proportion === '智能') {
|
||||
return { width: baseSize, height: baseSize }
|
||||
}
|
||||
|
||||
const [w, h] = String(proportion).split(':').map(Number)
|
||||
const aspectRatio = w / h
|
||||
|
||||
if (aspectRatio > 1) {
|
||||
return {
|
||||
width: baseSize,
|
||||
height: Math.round(baseSize / aspectRatio)
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
height: baseSize,
|
||||
width: Math.round(baseSize * aspectRatio)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function Playload(data) {
|
||||
try {
|
||||
const json = await fetchModelConfig(data.type, data.modelName, data.modelType)
|
||||
|
|
|
|||
Loading…
Reference in New Issue