[Go] 이미지 크기 가져오기
샘플 코드
main.go
package main
import (
	"fmt"
	"os"
	"image"
	_ "image/jpeg" // NOTE: jpeg 画像を読み込むために必要
	// _ "image/gif" // NOTE: gif 画像を読み込むために必要(今回は使用しません)
	// _ "image/png" // NOTE: png 画像を読み込むために必要(今回は使用しません)
)
func main() {
	file, err := os.Open("./example.jpeg")
	if err != nil {
		panic(err)
	}
	defer file.Close()
	// 画像を読み込み
	img, _, err := image.Decode(file)
	if err != nil {
		panic(err)
	}
	// 幅 -> img.Bounds().Dx()
	// 高さ -> img.Bounds().Dy()
	fmt.Println("width:", img.Bounds().Dx())
	fmt.Println("height:", img.Bounds().Dy())
	// => width: 1200
	//    height: 800
}
참고 자료
Reference
이 문제에 관하여([Go] 이미지 크기 가져오기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://zenn.dev/kou_pg_0131/articles/go-get-image-size텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)