use flag for image size

This commit is contained in:
Antoni Sawicki 2024-07-02 01:21:22 -07:00
parent a2a4152b86
commit b546b5cbae
2 changed files with 3 additions and 2 deletions

4
txt.go
View File

@ -197,8 +197,8 @@ func smallGif(src []byte) ([]byte, error) {
if err != nil { if err != nil {
return nil, fmt.Errorf("image decode problem: %v", err) return nil, fmt.Errorf("image decode problem: %v", err)
} }
if img.Bounds().Max.X-img.Bounds().Min.X > 200 { if img.Bounds().Max.X-img.Bounds().Min.X > *txtImgSize {
img = resize.Resize(200, 0, img, resize.NearestNeighbor) img = resize.Resize(uint(*txtImgSize), 0, img, resize.NearestNeighbor)
} }
var gifBuf bytes.Buffer var gifBuf bytes.Buffer
err = gif.Encode(&gifBuf, gifPalette(img, 216), &gif.Options{}) err = gif.Encode(&gifBuf, gifPalette(img, 216), &gif.Options{})

1
wrp.go
View File

@ -51,6 +51,7 @@ var (
headless = flag.Bool("h", true, "Headless mode / hide browser window (default true)") headless = flag.Bool("h", true, "Headless mode / hide browser window (default true)")
noDel = flag.Bool("n", false, "Do not free maps and images after use") noDel = flag.Bool("n", false, "Do not free maps and images after use")
defType = flag.String("t", "gif", "Image type: png|gif|jpg|txt") defType = flag.String("t", "gif", "Image type: png|gif|jpg|txt")
txtImgSize = flag.Int("ts", 200, "txt mode image size")
jpgQual = flag.Int("q", 80, "Jpeg image quality, default 80%") jpgQual = flag.Int("q", 80, "Jpeg image quality, default 80%")
fgeom = flag.String("g", "1152x600x216", "Geometry: width x height x colors, height can be 0 for unlimited") fgeom = flag.String("g", "1152x600x216", "Geometry: width x height x colors, height can be 0 for unlimited")
htmFnam = flag.String("ui", "wrp.html", "HTML template file for the UI") htmFnam = flag.String("ui", "wrp.html", "HTML template file for the UI")