Last active
November 16, 2024 05:40
Revisions
-
sergiotapia revised this gist
Dec 9, 2013 . 1 changed file with 16 additions and 16 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,27 +1,27 @@ package main import ( "fmt" "image" "os" _ "image/jpeg" _ "image/png" ) func main() { width, height := getImageDimension("rainy.jpg") fmt.Println("Width:", width, "Height:", height) } func getImageDimension(imagePath string) (int, int) { file, err := os.Open(imagePath) if err != nil { fmt.Fprintf(os.Stderr, "%v\n", err) } image, _, err := image.DecodeConfig(file) if err != nil { fmt.Fprintf(os.Stderr, "%s: %v\n", imagePath, err) } return image.Width, image.Height } -
sergiotapia created this gist
Dec 9, 2013 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ package main import ( "fmt" "image" "os" _ "image/jpeg" _ "image/png" ) func main() { width, height := getImageDimension("rainy.jpg") fmt.Println("Width:", width, "Height:", height) } func getImageDimension(imagePath string) (int, int) { file, err := os.Open(imagePath) if err != nil { fmt.Fprintf(os.Stderr, "%v\n", err) } image, _, err := image.DecodeConfig(file) if err != nil { fmt.Fprintf(os.Stderr, "%s: %v\n", imagePath, err) } return image.Width, image.Height }