Skip to content

Commit d0ebf1d

Browse files
committed
Merge branch 'dev-doc-aigc' into 'master' (merge request !141)
支持获取aigc和文档水印和文档aigc任务
2 parents a686f5c + cbe9485 commit d0ebf1d

File tree

6 files changed

+169
-21
lines changed

6 files changed

+169
-21
lines changed

ci.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2893,3 +2893,7 @@ type ImgTargetRecResult struct {
28932893
} `xml:"PlateDetailInfo"`
28942894
} `xml:"PlateDetailInfos"`
28952895
}
2896+
2897+
type AIGCResult struct {
2898+
AIGC string `json:"AIGC,omitempty"`
2899+
}

ci_doc.go

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,35 @@ type DocProcessJobOutput struct {
2020
Object string `xml:"Object,omitempty"`
2121
}
2222

23+
type DocWatermark struct {
24+
SrcType string `xml:"SrcType,omitempty"`
25+
Type string `xml:"Type,omitempty"`
26+
Image string `xml:"Image,omitempty"`
27+
Dx string `xml:"Dx,omitempty"`
28+
Dy string `xml:"Dy,omitempty"`
29+
}
30+
2331
type DocProcessJobDocProcess struct {
24-
SrcType string `xml:"SrcType,omitempty"`
25-
TgtType string `xml:"TgtType,omitempty"`
26-
SheetId int `xml:"SheetId,omitempty"`
27-
StartPage int `xml:"StartPage,omitempty"`
28-
EndPage int `xml:"EndPage,omitempty"`
29-
ImageParams string `xml:"ImageParams,omitempty"`
30-
DocPassword string `xml:"DocPassword,omitempty"`
31-
Comments int `xml:"Comments,omitempty"`
32-
PaperDirection int `xml:"PaperDirection,omitempty"`
33-
Quality int `xml:"Quality,omitempty"`
34-
Zoom int `xml:"Zoom,omitempty"`
35-
PaperSize int `xml:"PaperSize,omitempty"`
36-
ImageDpi int `xml:"ImageDpi,omitempty"`
37-
PicPagination int `xml:"PicPagination,omitempty"`
32+
SrcType string `xml:"SrcType,omitempty"`
33+
TgtType string `xml:"TgtType,omitempty"`
34+
SheetId int `xml:"SheetId,omitempty"`
35+
StartPage int `xml:"StartPage,omitempty"`
36+
EndPage int `xml:"EndPage,omitempty"`
37+
ImageParams string `xml:"ImageParams,omitempty"`
38+
DocPassword string `xml:"DocPassword,omitempty"`
39+
Comments int `xml:"Comments,omitempty"`
40+
PaperDirection int `xml:"PaperDirection,omitempty"`
41+
Quality int `xml:"Quality,omitempty"`
42+
Zoom int `xml:"Zoom,omitempty"`
43+
PaperSize int `xml:"PaperSize,omitempty"`
44+
ImageDpi int `xml:"ImageDpi,omitempty"`
45+
PicPagination int `xml:"PicPagination,omitempty"`
46+
DocWatermark *DocWatermark `xml:"DocWatermark,omitempty"`
47+
}
48+
49+
type WatermarkInfoResult struct {
50+
Size int `xml:"Size,omitempty"`
51+
Etag string `xml:"Etag,omitempty"`
3852
}
3953

4054
type DocProcessJobDocProcessResult struct {
@@ -51,13 +65,27 @@ type DocProcessJobDocProcessResult struct {
5165
PicIndex int `xml:"PicIndex,omitempty"`
5266
PicNum int `xml:"PicNum,omitempty"`
5367
} `xml:"PageInfo,omitempty"`
68+
WatermarkInfo *WatermarkInfoResult `xml:"WatermarkInfo,omitempty"`
69+
}
70+
71+
type DocWatermarkResult struct {
72+
Size int `xml:"Size,omitempty"`
73+
TotalPageCount int `xml:"TotalPageCount,omitempty"`
74+
Etag string `xml:"Etag,omitempty"`
75+
}
76+
77+
type DocAIGCMetadata struct {
78+
AIGCMetadata *AIGCMetadata `xml:"AIGCMetadata,omitempty"`
5479
}
5580

5681
type DocProcessJobOperation struct {
57-
Output *DocProcessJobOutput `xml:"Output,omitempty"`
58-
DocProcess *DocProcessJobDocProcess `xml:"DocProcess,omitempty"`
59-
DocProcessResult *DocProcessJobDocProcessResult `xml:"DocProcessResult,omitempty"`
60-
UserData string `xml:"UserData,omitempty"`
82+
Output *DocProcessJobOutput `xml:"Output,omitempty"`
83+
DocProcess *DocProcessJobDocProcess `xml:"DocProcess,omitempty"`
84+
DocAIGCMetadata *DocAIGCMetadata `xml:"DocAIGCMetadata,omitempty"`
85+
DocWatermark *DocWatermark `xml:"DocWatermark,omitempty"`
86+
DocProcessResult *DocProcessJobDocProcessResult `xml:"DocProcessResult,omitempty"`
87+
DocWatermarkResult *DocWatermarkResult `xml:"DocWatermarkResult,omitempty"`
88+
UserData string `xml:"UserData,omitempty"`
6189
}
6290

6391
type DocProcessJobDetail struct {

ci_media.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,7 @@ type NodeOperation struct {
20872087
TranscodeConfig *struct {
20882088
FreeTranscode string `xml:"FreeTranscode,omitempty" json:"FreeTranscode,omitempty"`
20892089
} `xml:"TranscodeConfig,omitempty" json:"TranscodeConfig,omitempty"`
2090+
DocAIGCMetadata *DocAIGCMetadata `xml:"DocAIGCMetadata,omitempty"`
20902091
}
20912092

20922093
// Node TODO
@@ -3508,6 +3509,7 @@ type InventoryTriggerJobOperationJobParam struct {
35083509
ImageInspectResult *ImageInspectResult `xml:"ImageInspectResult,omitempty"`
35093510
ImageOCR *ImageOCRTemplate `xml:"ImageOCR,omitempty"`
35103511
Detection *ImageOCRDetection `xml:"Detection,omitempty"`
3512+
DocAIGCMetadata *DocAIGCMetadata `xml:"DocAIGCMetadata,omitempty"`
35113513
}
35123514

35133515
// InventoryTriggerJob TODO

example/CI/doc_preview/job.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"context"
55
"fmt"
6+
"io/ioutil"
67
"net/http"
78
"net/url"
89
"os"
@@ -140,8 +141,78 @@ func describeDocJobs() {
140141
fmt.Printf("%+v\n", DescribeJobsRes)
141142
}
142143

144+
func getAIGC() {
145+
c := getClient()
146+
name := "3.pdf"
147+
opt := &cos.ObjectGetOptions{
148+
CiProcess: "DocAIGCMetadata",
149+
}
150+
resp, err := c.Object.Get(context.Background(), name, opt)
151+
log_status(err)
152+
bs, _ := ioutil.ReadAll(resp.Body)
153+
resp.Body.Close()
154+
fmt.Printf("%s\n", string(bs))
155+
}
156+
157+
func createAIGCDocJob() {
158+
c := getClient()
159+
160+
createJobOpt := &cos.CreateDocProcessJobsOptions{
161+
Tag: "DocAIGCMetadata",
162+
Input: &cos.DocProcessJobInput{
163+
Object: "abc.pdf",
164+
},
165+
Operation: &cos.DocProcessJobOperation{
166+
Output: &cos.DocProcessJobOutput{
167+
Region: "ap-chongqing",
168+
Object: "abc-aigc.pdf",
169+
Bucket: OutputBucket,
170+
},
171+
DocAIGCMetadata: &cos.DocAIGCMetadata{
172+
AIGCMetadata: &cos.AIGCMetadata{
173+
Label: "1",
174+
ContentProducer: "AIGC-Bqwdvi-1584",
175+
ProduceID: "CI-2025-XXXXX-${InputName}",
176+
},
177+
},
178+
},
179+
}
180+
createJobRes, _, err := c.CI.CreateDocProcessJobs(context.Background(), createJobOpt)
181+
log_status(err)
182+
fmt.Printf("%+v\n", createJobRes.JobsDetail)
183+
}
184+
185+
func createWatermarkDocJob() {
186+
c := getClient()
187+
188+
createJobOpt := &cos.CreateDocProcessJobsOptions{
189+
Tag: "DocWatermark",
190+
Input: &cos.DocProcessJobInput{
191+
Object: "abc.pdf",
192+
},
193+
Operation: &cos.DocProcessJobOperation{
194+
Output: &cos.DocProcessJobOutput{
195+
Region: "ap-chongqing",
196+
Object: "abc-watermark.pdf",
197+
Bucket: OutputBucket,
198+
},
199+
DocWatermark: &cos.DocWatermark{
200+
Type: "1",
201+
SrcType: "pdf",
202+
Image: "https://wwj-cq-125000000.cos.ap-chongqing.myqcloud.com/a.png",
203+
Dx: "10",
204+
Dy: "10",
205+
},
206+
},
207+
}
208+
createJobRes, _, err := c.CI.CreateDocProcessJobs(context.Background(), createJobOpt)
209+
log_status(err)
210+
fmt.Printf("%+v\n", createJobRes.JobsDetail)
211+
}
212+
143213
func main() {
144214
// createDocJob()
145215
// describeDocJob()
146216
// describeDocJobs()
217+
// getAIGC()
147218
}

example/CI/image_process/base_process.go

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/base64"
66
"fmt"
7+
"io/ioutil"
78
"net/http"
89
"net/url"
910
"os"
@@ -138,7 +139,7 @@ func processWhenCloud(ctx context.Context, rawurl, obj string, pic *cos.PicOpera
138139
}
139140

140141
// 云上数据处理
141-
func processWhenCloudWithHeader(ctx context.Context, rawurl, obj string, imageProcessHeader *cos.ImageProcessHeader ) {
142+
func processWhenCloudWithHeader(ctx context.Context, rawurl, obj string, imageProcessHeader *cos.ImageProcessHeader) {
142143
u, _ := url.Parse(rawurl)
143144
b := &cos.BaseURL{BucketURL: u}
144145
c := cos.NewClient(b, &http.Client{
@@ -1086,7 +1087,6 @@ func extractBlindWatermark3() {
10861087
}
10871088
}
10881089

1089-
10901090
// 文字水印和AIGC
10911091
func textWatermarkAndAIGC() {
10921092
rawurl := "https://test-12500000.cos.ap-chongqing.myqcloud.com"
@@ -1120,7 +1120,7 @@ func textWatermarkAndAIGC() {
11201120
}
11211121
processWhenUpload(context.Background(), rawurl, obj, filepath, pic)
11221122
}
1123-
1123+
11241124
// 云上数据处理
11251125
{
11261126
obj := "pic/deer.jpeg"
@@ -1158,6 +1158,36 @@ func textWatermarkAndAIGC() {
11581158

11591159
}
11601160

1161+
func getAIGC() {
1162+
u, _ := url.Parse("https://test-12500000.cos.ap-chongqing.myqcloud.com")
1163+
b := &cos.BaseURL{BucketURL: u}
1164+
c := cos.NewClient(b, &http.Client{
1165+
Transport: &cos.AuthorizationTransport{
1166+
// 通过环境变量获取密钥
1167+
// 环境变量 SECRETID 表示用户的 SecretId,登录访问管理控制台查看密钥,https://console.cloud.tencent.com/cam/capi
1168+
SecretID: os.Getenv("SECRETID"),
1169+
// 环境变量 SECRETKEY 表示用户的 SecretKey,登录访问管理控制台查看密钥,https://console.cloud.tencent.com/cam/capi
1170+
SecretKey: os.Getenv("SECRETKEY"),
1171+
// Debug 模式,把对应 请求头部、请求内容、响应头部、响应内容 输出到标准输出
1172+
Transport: &debug.DebugRequestTransport{
1173+
RequestHeader: true,
1174+
RequestBody: true,
1175+
ResponseHeader: true,
1176+
ResponseBody: false,
1177+
},
1178+
},
1179+
})
1180+
name := "pic/textwatermark/textwatermark.jpg"
1181+
opt := &cos.ObjectGetOptions{
1182+
CiProcess: "ImageAIGCMetadata",
1183+
}
1184+
resp, err := c.Object.Get(context.Background(), name, opt)
1185+
log_status(err)
1186+
bs, _ := ioutil.ReadAll(resp.Body)
1187+
resp.Body.Close()
1188+
fmt.Printf("%s\n", string(bs))
1189+
}
1190+
11611191
func main() {
11621192
// commonProcess()
11631193
}

example/CI/media_process/media_process.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,5 +166,18 @@ func DescribeCIBuckets() {
166166
fmt.Printf("%+v\n", len(res.CIBucketList))
167167
}
168168

169+
func getAIGC() {
170+
c := getClient()
171+
name := "123.mp4"
172+
opt := &cos.ObjectGetOptions{
173+
CiProcess: "MediaAIGCMetadata",
174+
}
175+
resp, err := c.Object.Get(context.Background(), name, opt)
176+
log_status(err)
177+
bs, _ := ioutil.ReadAll(resp.Body)
178+
resp.Body.Close()
179+
fmt.Printf("%s\n", string(bs))
180+
}
181+
169182
func main() {
170183
}

0 commit comments

Comments
 (0)