package himage

import "github.com/gohugoio/hugo/common/himage"

Package himage provides some high level image types and interfaces.

Index

Functions

func FrameDurationsToGifDelays

func FrameDurationsToGifDelays(frameDurations []int) []int

FrameDurationsToGifDelays converts frame durations in milliseconds to GIF delays in 100ths of a second.

func GifDelaysToFrameDurations

func GifDelaysToFrameDurations(delays []int) []int

GifDelaysToFrameDurations converts GIF delays in 100ths of a second to frame durations in milliseconds.

Types

type AnimatedImage

type AnimatedImage interface {
	image.Image        // The first frame.
	GetRaw() any       // *gif.GIF or *WEBP.
	GetLoopCount() int // Number of times to loop the animation. 0 means infinite.
	ImageFrames
}

AnimatedImage represents an animated image. This is currently supported for GIF and WebP images.

type ImageConfigProvider

type ImageConfigProvider interface {
	GetImageConfig() image.Config
}

ImageConfigProvider provides access to the image.Config of an image.

type ImageFrames

type ImageFrames interface {
	GetFrames() []image.Image

	// Frame durations in milliseconds.
	// Note that Gif frame durations are in 100ths of a second,
	// so they need to be multiplied by 10 to get milliseconds and vice versa.
	GetFrameDurations() []int

	SetFrames(frames []image.Image)
	SetWidthHeight(width, height int)
}

ImageFrames provides access to the frames of an animated image.

Source Files

image.go

Version
v0.153.4 (latest)
Published
Dec 28, 2025
Platform
linux/amd64
Imports
1 packages
Last checked
4 months ago

Tools for package owners.