MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / DecodeBase64ImageData

Function DecodeBase64ImageData

service/image.go:18–35  ·  view source on GitHub ↗
(base64String string)

Source from the content-addressed store, hash-verified

16)
17
18func DecodeBase64ImageData(base64String string) (image.Config, string, string, error) {
19 // 去除base64数据的URL前缀(如果有)
20 if idx := strings.Index(base64String, ","); idx != -1 {
21 base64String = base64String[idx+1:]
22 }
23
24 // 将base64字符串解码为字节切片
25 decodedData, err := base64.StdEncoding.DecodeString(base64String)
26 if err != nil {
27 fmt.Println("Error: Failed to decode base64 string")
28 return image.Config{}, "", "", fmt.Errorf("failed to decode base64 string: %s", err.Error())
29 }
30
31 // 创建一个bytes.Buffer用于存储解码后的数据
32 reader := bytes.NewReader(decodedData)
33 config, format, err := getImageConfig(reader)
34 return config, format, base64String, err
35}
36
37func DecodeBase64FileData(base64String string) (string, string, error) {
38 var mimeType string

Callers 4

DecodeBase64FileDataFunction · 0.85
GetImageFromUrlFunction · 0.85
getImageTokenFunction · 0.85

Calls 2

getImageConfigFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected