aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRose Hogenson <rosehogenson@posteo.net>2025-03-17 16:38:36 -0700
committerRose Hogenson <rosehogenson@posteo.net>2025-03-17 16:38:36 -0700
commit8896fdcf2c049a5b428ca1c49bf28fc2702c0ae1 (patch)
tree4c2a5a120b11a69abdff8d96bb19c3c34ad83da4
parent2ef107aee0b4e88b3335b04418ec0e27ad8ebbfc (diff)
downloadimgutil-8896fdcf2c049a5b428ca1c49bf28fc2702c0ae1.tar.zst
Print in double resolution using â–€
-rw-r--r--go.mod2
-rw-r--r--icat.go19
2 files changed, 13 insertions, 8 deletions
diff --git a/go.mod b/go.mod
index 94d1016..9019d01 100644
--- a/go.mod
+++ b/go.mod
@@ -1,4 +1,4 @@
-module icat
+module gitlab.com/rhogenson/icat
go 1.20
diff --git a/icat.go b/icat.go
index 1a8dd8a..15f10d1 100644
--- a/icat.go
+++ b/icat.go
@@ -3,12 +3,13 @@ package main
import (
"bufio"
"fmt"
- "golang.org/x/image/draw"
- "golang.org/x/term"
"image"
_ "image/jpeg"
_ "image/png"
"os"
+
+ "golang.org/x/image/draw"
+ "golang.org/x/term"
)
var stdout = bufio.NewWriter(os.Stdout)
@@ -45,16 +46,20 @@ func printImg(filename string, cols, lines int) error {
cols = img.Bounds().Dx() * lines * 5 / 2 / img.Bounds().Dy()
}
- dst := image.NewRGBA(image.Rect(0, 0, cols, lines))
- draw.ApproxBiLinear.Scale(dst, dst.Bounds(), img, img.Bounds(), draw.Over, nil)
+ dst := image.NewRGBA(image.Rect(0, 0, cols, 2*lines))
+ draw.CatmullRom.Scale(dst, dst.Bounds(), img, img.Bounds(), draw.Over, nil)
- for y := 0; y < lines; y++ {
+ for y := 0; y < 2*lines; y += 2 {
for x := 0; x < cols; x++ {
- r, g, b, _ := dst.At(x, y).RGBA()
- fmt.Fprintf(stdout, "\033[48;2;%d;%d;%dm ", r>>8, g>>8, b>>8)
+ hiR, hiG, hiB, _ := dst.At(x, y).RGBA()
+ loR, loG, loB, _ := dst.At(x, y+1).RGBA()
+ fmt.Fprintf(stdout, "\033[38;2;%d;%d;%dm\033[48;2;%d;%d;%dmâ–€",
+ hiR>>8, hiG>>8, hiB>>8,
+ loR>>8, loG>>8, loB>>8)
}
fmt.Fprintln(stdout, "\033[49m")
}
+ fmt.Fprint(stdout, "\033[39m")
return nil
}