2 Star 0 Fork 0

ixuer / gopdf_example

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
image_size.go 472 Bytes
一键复制 编辑 原始数据 按行查看 历史
ixuer 提交于 2022-11-24 20:14 . add test case.
package utils
import (
"image"
_ "image/jpeg"
_ "image/png"
"os"
)
// GetImageSize get image width and height.
// if error is "image: unknown format",
// import the image package of file suffix,
// like '_ "image/png"' or '_ "image/jpeg"'.
func GetImageSize(filePath string) (int, int) {
f, err := os.Open(filePath)
if err != nil {
return 0, 0
}
config, _, err := image.DecodeConfig(f)
if err != nil {
return 0, 0
}
return config.Width, config.Height
}
Go
1
https://gitee.com/ixuer/gopdf_example.git
git@gitee.com:ixuer/gopdf_example.git
ixuer
gopdf_example
gopdf_example
cdfabb8c36a7

搜索帮助