Help us shape the future of Go! Take the 2026 Go Developer Survey

thumbkit

package
v0.56.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package thumbkit helps an app draw thumbnails (filex 0.50 and later): the answer's encoding, and a card of lines in the look filex's own archive and text thumbnails have - what an app that lists a file's contents (an archive kind filex does not read, a package, a playlist) wants to draw.

pluginkit.Run(&pluginkit.Plugin{
	Manifest:  manifest,
	Thumbnail: func(in *wire.ThumbnailInput) (*wire.ThumbnailOutput, error) {
		src, err := pluginkit.ThumbnailSource(in)
		if err != nil {
			return nil, err
		}
		defer src.Close()
		names, err := listMyFormat(src)
		if err != nil {
			return nil, err // filex asks the next handler
		}
		return thumbkit.PNG(thumbkit.ListCard("MYFMT · 12 files", names, 0))
	},
})

It is plain Go (image, image/png and the 7x13 bitmap face of golang.org/x/image), so it works the same off-wasm, in a test.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListCard

func ListCard(header string, lines []string, more int) image.Image

ListCard draws header across the top and lines under it, as many as fit, each cut to the card's width; more > 0 adds "+N more" under the list. Letters outside ASCII are drawn as "?": the face is a 7x13 bitmap, small enough for every app to carry.

func PNG

func PNG(img image.Image) (*wire.ThumbnailOutput, error)

PNG encodes img as a thumbnail answer, refusing what filex would refuse: an image wider or taller than wire.ThumbnailMaxPixels, or one heavier than wire.ThumbnailMaxOutputBytes once encoded.

Types

This section is empty.

Jump to

Keyboard shortcuts

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