@@ -11,7 +11,11 @@ import (
11
11
12
12
"github.com/BourgeoisBear/rasterm"
13
13
"github.com/hilli/icat/util"
14
+
14
15
ascii "github.com/qeesung/image2ascii/convert"
16
+
17
+ _ "golang.org/x/image/bmp"
18
+ _ "golang.org/x/image/tiff"
15
19
_ "golang.org/x/image/webp"
16
20
)
17
21
@@ -68,7 +72,7 @@ func PrintImageURL(imageURL string) error {
68
72
return PrintImage (img , & imageConfig , imageURL , resp .ContentLength )
69
73
}
70
74
71
- func PrintImage (image * image.Image , imageConfig * image.Config , filename string , imageSize int64 ) error {
75
+ func PrintImage (img * image.Image , imageConfig * image.Config , filename string , imageSize int64 ) error {
72
76
sixelCapable , _ := rasterm .IsSixelCapable ()
73
77
74
78
_ , _ , pw , ph := TermSize () // Get terminal height and width in pixels
@@ -82,24 +86,29 @@ func PrintImage(image *image.Image, imageConfig *image.Config, filename string,
82
86
kittyOpts .SrcHeight = uint32 (ph )
83
87
}
84
88
89
+ // resizedImage := resizeImage(*img, kittyOpts.SrcHeight)
90
+
85
91
switch {
86
92
case rasterm .IsKittyCapable ():
87
- return rasterm .KittyWriteImage (os .Stdout , * image , kittyOpts )
93
+ return rasterm .KittyWriteImage (os .Stdout , * img , kittyOpts )
88
94
89
95
case rasterm .IsItermCapable ():
90
- rasterm .ItermWriteImageWithOptions (os .Stdout , * image , rasterm.ItermImgOpts {Width : string (imageConfig .Width ), Height : string (imageConfig .Height ), Name : filename , DisplayInline : true })
91
- // rasterm.ItermCopyFileInlineWithOptions()
92
- return rasterm .ItermWriteImage (os .Stdout , * image )
96
+ return rasterm .ItermWriteImage (os .Stdout , * img )
93
97
94
98
case sixelCapable :
95
99
// TODO: Convert image to a paletted format
96
- // return rasterm.SixelWriteImage(os.Stdout, *image)
100
+ // if iPaletted, bOK := img.(*image.Paletted); bOK {
101
+ // return rasterm.SixelWriteImage(os.Stdout, iPaletted)
102
+ // } else {
103
+ // fmt.Println("[NOT PALETTED, SKIPPING.]")
104
+ // return nil
105
+ // }
97
106
98
107
default :
99
108
// Ascii art fallback
100
109
converter := ascii .NewImageConverter ()
101
110
convertOptions := ascii .DefaultOptions
102
- fmt .Print ("\n " , converter .Image2ASCIIString (* image , & convertOptions )) // Align image at the initial position instead of \n first?
111
+ fmt .Print ("\n " , converter .Image2ASCIIString (* img , & convertOptions )) // Align image at the initial position instead of \n first?
103
112
}
104
113
return nil
105
114
}
0 commit comments