images

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2024 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const TempTemplate = "kitty-tty-graphics-protocol-*"

Variables

View Source
var DecodableImageTypes = map[string]bool{
	"image/jpeg": true, "image/png": true, "image/bmp": true, "image/tiff": true, "image/webp": true, "image/gif": true,
}
View Source
var EncodableImageTypes = map[string]bool{
	"image/jpeg": true, "image/png": true, "image/bmp": true, "image/tiff": true, "image/gif": true,
}
View Source
var MagickExe = sync.OnceValue(func() string {
	return utils.FindExe("magick")
})
View Source
var NRGBModel color.Model = color.ModelFunc(nrgbModel)
View Source
var NumberToDiacritic = [297]rune{}/* 297 elements not displayed */

Functions

func CalcMinimumGIFGap

func CalcMinimumGIFGap(gaps []int) int

func ConvertEntryPoint

func ConvertEntryPoint(root *cli.Command)

func CreateTemp

func CreateTemp() (*os.File, error)

func CreateTempInRAM

func CreateTempInRAM() (*os.File, error)

func Encode

func Encode(output io.Writer, img image.Image, format_mime string) (err error)

func FitImage

func FitImage(width, height, pwidth, pheight int) (final_width int, final_height int)

func IsOpaque

func IsOpaque(img image.Image) bool

func MakeTempDir

func MakeTempDir(template string) (ans string, err error)

func RunMagick

func RunMagick(path string, cmd []string) ([]byte, error)

func SetGIFFrameDisposal

func SetGIFFrameDisposal(number, anchor_frame int, disposal byte) (int, int)

Types

type Context

type Context struct {
	// contains filtered or unexported fields
}

func (*Context) FlipPixelsH

func (self *Context) FlipPixelsH(bytes_per_pixel, width, height int, pix []uint8)

func (*Context) FlipPixelsV

func (self *Context) FlipPixelsV(bytes_per_pixel, width, height int, pix []uint8)

func (*Context) NumberOfThreads

func (self *Context) NumberOfThreads() int

func (*Context) Parallel

func (self *Context) Parallel(start, stop int, fn func(<-chan int))

parallel processes the data in separate goroutines.

func (*Context) Paste

func (self *Context) Paste(background image.Image, img image.Image, pos image.Point, opaque_bg *NRGBColor)

Paste pastes the img image to the background image at the specified position. Optionally composing onto the specified opaque color.

func (*Context) PasteCenter

func (self *Context) PasteCenter(background image.Image, img image.Image, opaque_bg *NRGBColor)

PasteCenter pastes the img image to the center of the background image. Optionally composing onto the specified opaque color.

func (*Context) SetNumberOfThreads

func (self *Context) SetNumberOfThreads(n int)

type IdentifyOutput

type IdentifyOutput struct {
	Fmt, Canvas, Transparency, Gap, Index, Size, Dpi, Dispose, Orientation string
}

type IdentifyRecord

type IdentifyRecord struct {
	Fmt_uppercase      string
	Gap                int
	Canvas             struct{ Width, Height, Left, Top int }
	Width, Height      int
	Dpi                struct{ X, Y float64 }
	Index              int
	Is_opaque          bool
	Needs_blend        bool
	Disposal           int
	Dimensions_swapped bool
}

func IdentifyWithMagick

func IdentifyWithMagick(path string) (ans []IdentifyRecord, err error)

type ImageData

type ImageData struct {
	Width, Height    int
	Format_uppercase string
	Frames           []*ImageFrame
}

func OpenImageFromPath

func OpenImageFromPath(path string) (ans *ImageData, err error)

func OpenImageFromPathWithMagick

func OpenImageFromPathWithMagick(path string) (ans *ImageData, err error)

func OpenNativeImageFromReader

func OpenNativeImageFromReader(f io.ReadSeeker) (ans *ImageData, err error)

func (*ImageData) Resize

func (self *ImageData) Resize(x_frac, y_frac float64) *ImageData

type ImageFrame

type ImageFrame struct {
	Width, Height, Left, Top int
	Number                   int   // 1-based number
	Compose_onto             int   // number of frame to compose onto
	Delay_ms                 int32 // negative for gapless frame, zero ignored, positive is number of ms
	Is_opaque                bool
	Img                      image.Image
}

func RenderWithMagick

func RenderWithMagick(path string, ro *RenderOptions, frames []IdentifyRecord) (ans []*ImageFrame, fmap map[int]string, err error)

func (*ImageFrame) Data

func (self *ImageFrame) Data() (ans []byte)

func (*ImageFrame) DataAsSHM

func (self *ImageFrame) DataAsSHM(pattern string) (ans shm.MMap, err error)

func (*ImageFrame) Resize

func (self *ImageFrame) Resize(x_frac, y_frac float64) *ImageFrame

type NRGB

type NRGB struct {
	// Pix holds the image's pixels, in R, G, B, A order. The pixel at
	// (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*4].
	Pix []uint8
	// Stride is the Pix stride (in bytes) between vertically adjacent pixels.
	Stride int
	// Rect is the image's bounds.
	Rect image.Rectangle
}

NRGB is an in-memory image whose At method returns NRGBColor values.

func NewNRGB

func NewNRGB(r image.Rectangle) *NRGB

func (*NRGB) At

func (p *NRGB) At(x, y int) color.Color

func (*NRGB) Bounds

func (p *NRGB) Bounds() image.Rectangle

func (*NRGB) ColorModel

func (p *NRGB) ColorModel() color.Model

func (*NRGB) NRGBAt

func (p *NRGB) NRGBAt(x, y int) NRGBColor

func (*NRGB) Opaque

func (p *NRGB) Opaque() bool

Opaque scans the entire image and reports whether it is fully opaque.

func (*NRGB) PixOffset

func (p *NRGB) PixOffset(x, y int) int

PixOffset returns the index of the first element of Pix that corresponds to the pixel at (x, y).

func (*NRGB) Set

func (p *NRGB) Set(x, y int, c color.Color)

func (*NRGB) SetNRGBA

func (p *NRGB) SetNRGBA(x, y int, c color.NRGBA)

func (*NRGB) SetRGBA64

func (p *NRGB) SetRGBA64(x, y int, c color.RGBA64)

func (*NRGB) SubImage

func (p *NRGB) SubImage(r image.Rectangle) image.Image

SubImage returns an image representing the portion of the image p visible through r. The returned value shares pixels with the original image.

type NRGBColor

type NRGBColor struct {
	R, G, B uint8
}

func (NRGBColor) AsSharp

func (c NRGBColor) AsSharp() string

func (NRGBColor) RGBA

func (c NRGBColor) RGBA() (r, g, b, a uint32)

type RenderOptions

type RenderOptions struct {
	RemoveAlpha          *NRGBColor
	Flip, Flop           bool
	ResizeTo             image.Point
	OnlyFirstFrame       bool
	TempfilenameTemplate string
}

type Scanner

type Scanner interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL