1
+
1
2
package main
2
3
3
4
import (
@@ -8,34 +9,55 @@ import (
8
9
"image/jpeg"
9
10
)
10
11
11
- func main () {
12
- // call to load the iages
13
- img := loadImage ("../images/78771293.jpg" )
14
-
15
- // loading all the data for images
16
- r ,g ,b ,a := img .At (0 ,0 ).RGBA ()
17
-
18
- // print the informaton
19
- fmt .Printf ("%d %d %d %d \n " , r ,g ,b ,a )
12
+ type loadimage interface {
13
+ LoadImage () image.Image
14
+ }
20
15
16
+ type imagen struct {
17
+ filename string
21
18
}
22
19
23
- func loadImage ( filename string ) image.Image {
24
-
25
- // get the files and return and images
26
- f , err := os .Open (filename )
20
+ func ( fil imagen ) LoadImage ( ) image.Image {
21
+
22
+ fmt . Println ( "loading interfaces" )
23
+ f , err := os .Open (fil . filename )
27
24
28
25
if err != nil {
29
26
log .Fatal (err )
30
27
}
31
28
32
29
defer f .Close ()
33
30
34
- img , err := jpeg .Decode (f )
31
+ // get the information of the file
32
+ fi , _ := f .Stat ()
33
+
34
+ fmt .Println ("File name: \t \t " , fi .Name ())
35
+ fmt .Println ("File Size: \t \t " , fi .Size ())
36
+ fmt .Println ("File Mode: \t \t " , fi .Mode ())
37
+ fmt .Println ("File ModTime: \t \t " , fi .ModTime ())
38
+ fmt .Println ("File Is Directory: \t \t " , fi .IsDir ())
39
+ fmt .Println ("File Sys: \t \t " , fi .Sys ())
40
+
41
+ imgn , err := jpeg .Decode (f )
35
42
36
43
if err != nil {
37
44
log .Fatal (err )
38
45
}
39
46
40
- return img
41
- }
47
+ return imgn
48
+ }
49
+
50
+ func main () {
51
+
52
+ // call to load the iages
53
+ img := imagen { filename : "../images/78771293.jpg" }
54
+
55
+ // loading all the data for images
56
+ r ,g ,b ,a := img .LoadImage ().At (0 ,0 ).RGBA ()
57
+
58
+ // print the informaton
59
+ fmt .Printf ("%d %d %d %d \n " , r ,g ,b ,a )
60
+
61
+ }
62
+
63
+
0 commit comments