Skip to content

Commit 75f4b5e

Browse files
committed
Rename image to img to avoid confusion with image package
1 parent fa5d172 commit 75f4b5e

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

print_image.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ import (
1111

1212
"github.com/BourgeoisBear/rasterm"
1313
"github.com/hilli/icat/util"
14+
1415
ascii "github.com/qeesung/image2ascii/convert"
16+
17+
_ "golang.org/x/image/bmp"
18+
_ "golang.org/x/image/tiff"
1519
_ "golang.org/x/image/webp"
1620
)
1721

@@ -68,7 +72,7 @@ func PrintImageURL(imageURL string) error {
6872
return PrintImage(img, &imageConfig, imageURL, resp.ContentLength)
6973
}
7074

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 {
7276
sixelCapable, _ := rasterm.IsSixelCapable()
7377

7478
_, _, pw, ph := TermSize() // Get terminal height and width in pixels
@@ -82,24 +86,29 @@ func PrintImage(image *image.Image, imageConfig *image.Config, filename string,
8286
kittyOpts.SrcHeight = uint32(ph)
8387
}
8488

89+
// resizedImage := resizeImage(*img, kittyOpts.SrcHeight)
90+
8591
switch {
8692
case rasterm.IsKittyCapable():
87-
return rasterm.KittyWriteImage(os.Stdout, *image, kittyOpts)
93+
return rasterm.KittyWriteImage(os.Stdout, *img, kittyOpts)
8894

8995
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)
9397

9498
case sixelCapable:
9599
// 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+
// }
97106

98107
default:
99108
// Ascii art fallback
100109
converter := ascii.NewImageConverter()
101110
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?
103112
}
104113
return nil
105114
}

0 commit comments

Comments
 (0)