Documentation ¶
Overview ¶
Package rasterm provides a simple way to encode images as terminal graphics, supporting Kitty, iTerm, and Sixel.
Example ¶
package main import ( "image" "os" "github.com/kenshaw/rasterm" _ "image/png" ) func main() { f, err := os.OpenFile("/path/to/image.png", os.O_RDONLY, 0) if err != nil { panic(err) } img, _, err := image.Decode(f) if err != nil { panic(err) } if err := rasterm.Encode(os.Stdout, img); err != nil { panic(err) } }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultJPEGQuality = 93
DefaultJPEGQuality is the default JPEG encode quality.
Functions ¶
Types ¶
type DefaultEncoder ¶
type DefaultEncoder struct {
// contains filtered or unexported fields
}
DefaultEncoder wraps multiple terminal graphic encoders.
func NewDefaultEncoder ¶
func NewDefaultEncoder(v ...Encoder) *DefaultEncoder
NewDefaultEncoder creates a wrapper for multiple terminal graphic encoders.
func (*DefaultEncoder) Available ¶
func (r *DefaultEncoder) Available() bool
Available satisfies the Encoder interface.
type Encoder ¶
Encoder provides a common interface for terminal graphic encoders.
func NewITermEncoder ¶
func NewITermEncoder() Encoder
NewITermEncoder creates a iTerm terminal graphics encoder.
func NewKittyEncoder ¶
func NewKittyEncoder() Encoder
NewKittyEncoder creates a Kitty terminal graphics encoder.
func NewSixelEncoder ¶
func NewSixelEncoder() Encoder
NewSixelEncoder creates a Sixel terminal graphics encoder.
type Error ¶
type Error string
Error is an error.
const ( // ErrTermGraphicsNotAvailable is the term graphics not available error. ErrTermGraphicsNotAvailable Error = "term graphics not available" // ErrNonTTY is the non tty error. ErrNonTTY Error = "non tty" // ErrTermResponseTimedOut is the term response timed out error. ErrTermResponseTimedOut Error = "term response timed out" // ErrUnknownTermType is the unknown term type error. ErrUnknownTermType Error = "unknown term type" )
type ITermEncoder ¶
type ITermEncoder struct {
NoNewline bool
}
ITermEncoder is a iTerm terminal graphics encoder.
See: https://iterm2.com/documentation-images.html
func (ITermEncoder) Available ¶
func (ITermEncoder) Available() bool
Available satisfies the Encoder interface.
type KittyEncoder ¶
type KittyEncoder struct {
NoNewline bool
}
KittyEncoder is a Kitty terminal graphics encoder.
func (KittyEncoder) Available ¶
func (KittyEncoder) Available() bool
Available satisfies the Encoder interface.
type SixelEncoder ¶
type SixelEncoder struct {
NoNewline bool
}
SixelEncoder is a Sixel terminal graphics encoder.
See: https://saitoha.github.io/libsixel/
func (SixelEncoder) Available ¶
func (SixelEncoder) Available() bool
Available satisfies the Encoder interface.
type TermType ¶
type TermType uint8
TermType is a terminal graphics type.
Terminal graphics types.
func (TermType) EnvValue ¶ added in v0.1.6
EnvValue returns the environment value name for the type.
func (TermType) MarshalText ¶ added in v0.1.5
MarshalText satisfies the encoding.TextMarshaler interface.
func (TermType) String ¶
String satisfies the fmt.Stringer interface.
func (*TermType) UnmarshalText ¶ added in v0.1.5
UnmarshalText satisfies the encoding.TextUnmarshaler interface.