@@ 1,11 1,14 @@
package main
import (
+ "crypto/tls"
"flag"
"fmt"
"image"
+ "io"
"log"
"math"
+ "net/http"
"os"
"strings"
@@ 64,24 67,41 @@ func main() {
var width, height int
var resizeBy string
var filter string
+ var tlsInsecure bool
flag.StringVar(&resizeBy, "resize-by", "fit", "resize image based on (fill,fit,height,width)")
flag.StringVar(&filter, "filter", "lanczos", "resample filter (box, catmullrom, gaussian, lanczos, linear, mitchellnetravali, nearest)")
flag.IntVar(&height, "height", defaultheight, "image height")
flag.IntVar(&width, "width", defaultwidth, "image width")
+ flag.BoolVar(&tlsInsecure, "insecure", false, "do not verify tls certificates")
flag.Parse()
+ if tlsInsecure {
+ http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
+ }
+
+ var ir io.ReadCloser
+ var ierr error
for _, fpath := range flag.Args() {
- ifile, ierr := os.Open(fpath)
- if ierr != nil {
- log.Fatalln(ierr)
+ if strings.HasPrefix(fpath, "http") {
+ var resp *http.Response
+ resp, ierr = http.Get(fpath)
+ if ierr != nil {
+ log.Fatalln(ierr)
+ }
+ ir = resp.Body
+ } else {
+ ir, ierr = os.Open(fpath)
+ if ierr != nil {
+ log.Fatalln(ierr)
+ }
}
- img, _, derr := imageorient.Decode(ifile)
+ img, _, derr := imageorient.Decode(ir)
if derr != nil {
log.Println(derr)
}
- ifile.Close()
+ ir.Close()
switch filter {
case "box":
@@ 11,6 11,8 @@ timv is an image viewer for the terminal.
It outputs in truecolor if supported, with the image sized to fit in the terminal.
In the case where the output is not a terminal, the output defaults to ANSI 256 colors
with a size of 80x24.
+.PP
+Paths can be local paths, or urls.
.SH OPTIONS
.HP
\fB\-filter\-by\fR \fIFILTER\fP
@@ 44,6 46,10 @@ Resample filter used for interplation. The following are supported:
.IP
Set height of image (defaults to termial height).
.HP
+\fB\-insecure\fR
+.IP
+Do not verify TLS certificates when requesting files over HTTPS.
+.HP
\fB\-resize\-by\fR \fITYPE\fP
.IP
Resize image to fit inside the specified width and height. The following types