MCPcopy Create free account
hub / github.com/astercloud/aster / GetImageDimensions

Method GetImageDimensions

pkg/media/processor.go:68–81  ·  view source on GitHub ↗

GetImageDimensions 获取图片尺寸

(path string)

Source from the content-addressed store, hash-verified

66
67// GetImageDimensions 获取图片尺寸
68func (p *Processor) GetImageDimensions(path string) (width, height int, err error) {
69 file, err := os.Open(path)
70 if err != nil {
71 return 0, 0, err
72 }
73 defer func() { _ = file.Close() }()
74
75 img, _, err := image.DecodeConfig(file)
76 if err != nil {
77 return 0, 0, err
78 }
79
80 return img.Width, img.Height, nil
81}
82
83// ValidateVideo 验证视频
84func (p *Processor) ValidateVideo(video *Video) error {

Callers

nothing calls this directly

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected