module
Version:
v1.2.0
Opens a new window with list of versions in this module.
Published: Jul 18, 2024
License: MulanPSL-2.0
Opens a new window with license information.
README
¶
TextToImg
介绍
文字转图片,中日韩等特殊字符支持,需要其它特殊字体生成请自行加入列表(先匹配上的文字优先渲染)
编译测试
cd text-to-img\test
go build -o .\test.exe .
.\test.exe
执行后即可看到同目录已经生成对应的图片
使用说明
-
引入扩展
go get gitee.com/archn/tony
-
加载依赖
go mod tidy
-
导入方法
import "gitee.com/archn/tony/text-to-img/toimage
-
使用方法:
-
toimage.RenderTextToPNG(text string, fontPaths []string, outputOrFile any, args ...TextToPngArgs) error
文字转换为图片方法,用于常规海报生成等
fontPaths 默认使用内置字体 如果要新增请注意 排序靠前的优先匹配
outputOrFile 可以是文件名称路径(绝对路径请已/开头)、也可以是文件句柄os.File用于内容写入
args 为可选参数,用于配置文字的颜色大小图片大小等基本信息详情请关注对应结构体,(默认12px|黑色|自适应)
-
toimage.ConvertRemoteImageToPNG(imageURL string, output *os.File) error
任意图片转png方法
引入包以后直接使用对应方法即可
Directories
¶
text-to-img
|
|
|
|
|
|
|
|
Click to show internal directories.
Click to hide internal directories.