💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] > [参考](https://github.com/fogleman/gg) ## 概述 ## 实例 <details> <summary>data/fb.csv</summary> ``` 编号,责任人,部门,启动时间,硬盘序列号 demo1,陈鹏杰,demo3,demo4,demo5 demo11,demo12,demo13,demo14,demo15 demo21,demo22,demo23,demo24,demo25 ``` </details> <br/> <details> <summary>main.go</summary> ``` package main import ( "fmt" "github.com/fogleman/gg" "io/ioutil" "strings" ) func main() { jpg, err := gg.LoadJPG("data/fb.jpg") if err != nil { panic(err) } dc := gg.NewContext(5306, 2913) if err := dc.LoadFontFace("data/font.ttf", 96); err != nil { panic(err) } dc.SetRGB(0, 0, 0) csv := getCSV("data/fb.csv") for _, v := range csv { dc.Clear() dc.DrawImage(jpg,0,0) dc.DrawString(v[0],3700, 600) dc.DrawString(v[1],3850, 1000) dc.DrawString(v[2],3700, 1400) dc.DrawString(v[3],4000, 1800) dc.DrawString(v[4],4200, 2200) err := dc.SavePNG(fmt.Sprintf("output/%s.png", v[1])) if err != nil { panic(err) } } } func getCSV(file string) [][]string { content, err := ioutil.ReadFile(file) if err != nil { panic(err) } contentString:=string(content) contArr := strings.Split(contentString, "\n")[1:] var resArr [][]string for _, line := range contArr { split := strings.Split(line, ",") resArr = append(resArr, split) } return resArr } ``` </details> <br/>