|
@@ -18,7 +18,7 @@ type ImageInfo struct {
|
|
|
dc *gg.Context
|
|
|
}
|
|
|
|
|
|
-func (im *ImageInfo) Runimage(sql string) ([]byte, error) {
|
|
|
+func (im *ImageInfo) testRunimage(sql string) ([]byte, error) {
|
|
|
// 创建一个新的gg.Context实例,根据字符串长度动态设置图像大小
|
|
|
const padding = 20 // 上下留白
|
|
|
const charWidth = 10 // 字符宽度
|
|
@@ -104,14 +104,14 @@ func (im *ImageInfo) Runimage(sql string) ([]byte, error) {
|
|
|
return buf.Bytes(), nil
|
|
|
}
|
|
|
|
|
|
-func (im *ImageInfo) Runimage2(sql string) ([]byte, error) {
|
|
|
+func (im *ImageInfo) Runimage(sql string) ([]byte, error) {
|
|
|
// 设置图片大小
|
|
|
width := 100
|
|
|
height := 100
|
|
|
|
|
|
// 设置字体和字体大小
|
|
|
fontSize := 20.0
|
|
|
- fontPath := "/home/gtong/xugu_work/xg_autotest/assets/SimHei.ttf"
|
|
|
+ fontPath := "./assets/SimHei.ttf"
|
|
|
|
|
|
// 根据字符串长度调整图片宽度和高度
|
|
|
dcTemp := gg.NewContext(100, 100)
|
|
@@ -137,7 +137,7 @@ func (im *ImageInfo) Runimage2(sql string) ([]byte, error) {
|
|
|
//设置高度
|
|
|
height += lineHeight * int(fontSize*1.2)
|
|
|
// 创建一个新的绘图上下文
|
|
|
- width = int(width) * 4 // 保留一些空白边距
|
|
|
+ width = int(width) * 2 // 保留一些空白边距
|
|
|
|
|
|
im.dc = gg.NewContext(width, height)
|
|
|
// 加载字体和字体大小
|