Documentation
¶
Overview ¶
Package imgcat provides a writer useful to show images directly into iterm2.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsSupported ¶
func IsSupported() bool
IsSupported check whether imgcat works in the current terminal.
Types ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
An Encoder is used to encode images to iterm2.
func NewEncoder ¶
NewEncoder returns a encoder that encodes images for iterm2.
Example ¶
package main import ( "log" "os" "github.com/campoy/tools/imgcat" ) func main() { enc, err := imgcat.NewEncoder(os.Stdout, imgcat.Width(imgcat.Pixels(100)), imgcat.Inline(true), imgcat.Name("smiley.png")) if err != nil { log.Fatal(err) } f, err := os.Open("testdata/icon.png") if err != nil { log.Fatal(err) } defer func() { _ = f.Close() }() // Display the image in the terminal. if err := enc.Encode(f); err != nil { log.Fatal(err) } }
Output:
func (*Encoder) Writer ¶
func (enc *Encoder) Writer() io.WriteCloser
Writer creates a writer that will encode whatever is written to it.
type Length ¶
type Length string
Length is used by the Width and Height options.
type Option ¶
type Option string
An Option modifies how an image is displayed.
func Inline ¶
Inline set to true causes the to be displayed inline. Otherwise, it will be downloaded with no visual representation in the terminal session. Defaults to false.
func PreserveAspectRatio ¶
PreserveAspectRatio set to false causes the image's inherent aspect ratio will not be respected; otherwise, it will fill the specified width and height as much as possible without stretching. Defaults to true.