feat:ai生成图文新增选择分辨率

This commit is contained in:
bx1834938347-prog 2025-12-12 09:51:56 +08:00
parent 92c6089096
commit 0a14025092
2 changed files with 8 additions and 1 deletions

View File

@ -42,6 +42,7 @@ type excelData struct {
Content string //内容 Content string //内容
MediaAccountUuids []string MediaAccountUuids []string
MediaAccountNames []string MediaAccountNames []string
PhotoDpi string
} }
type publishImageReq struct { type publishImageReq struct {
ArtistName string //艺人 ArtistName string //艺人
@ -197,6 +198,7 @@ func readExcel(excelPath string) ([]excelData, error) {
photoRequire := getCellValue(f, sheetName, i, 7) photoRequire := getCellValue(f, sheetName, i, 7)
photoUrl := getCellValue(f, sheetName, i, 8) photoUrl := getCellValue(f, sheetName, i, 8)
photoNumStr := getCellValue(f, sheetName, i, 9) photoNumStr := getCellValue(f, sheetName, i, 9)
photoDpi := getCellValue(f, sheetName, i, 10)
var num int var num int
if photoUrl == "" { //如果没有关联画作,数量必须有,需求必须有 if photoUrl == "" { //如果没有关联画作,数量必须有,需求必须有
//需求必须有 //需求必须有
@ -227,6 +229,7 @@ func readExcel(excelPath string) ([]excelData, error) {
PhotoUrl: photoUrl, PhotoUrl: photoUrl,
PhotoNum: num, PhotoNum: num,
LineNum: i, //行数 LineNum: i, //行数
PhotoDpi: photoDpi,
} }
result = append(result, data) result = append(result, data)

View File

@ -650,9 +650,13 @@ func (p *BatchProcessor) generateImage(req *excelData) (string, error) {
prompt += "\n请基于标题和内容生成单张图片高质量高分辨率。" prompt += "\n请基于标题和内容生成单张图片高质量高分辨率。"
prompt += "\n要求不能出现:低质量、残缺、人物正脸、多余的手指、乱码字符和文字、比例不良,场景以国内场景为主" prompt += "\n要求不能出现:低质量、残缺、人物正脸、多余的手指、乱码字符和文字、比例不良,场景以国内场景为主"
if req.PhotoDpi == "" {
req.PhotoDpi = "720*1280"
}
result, err := NewAiGenerator().TextToImage( result, err := NewAiGenerator().TextToImage(
prompt, prompt,
"1024*1024", req.PhotoDpi,
1, 1,
) )
if err != nil { if err != nil {