thumbnail

package
v0.0.0-...-cdd0a96 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ThumbnailWidth  = 300
	ThumbnailHeight = 300
	ThumbnailSuffix = "thumb"
)

Functions

func CenterResize

func CenterResize(src image.Image, width int, height int) (image.Image, error)

CenterResize by:

  1. Finding the smallest dimension (width or height)
  2. Scaling the image down while keeping aspect ratio
  3. Cropping excess from largest dimension (width or height) by cutting an equal amount on both sides, leaving the image centered

4. Store the resized version with suffix

func CreateThumbnail

func CreateThumbnail(i model.Item) (model.Image, error)

CreateThumbnail by looking at the image MIMEtype and then take appropriate actions to create it.

For images, scale the image to 300x300px without changing the ratio by first scaling it by the smallest side too 300px, then cropping/trimming the excess of the longest side

func GetThumbnailPath

func GetThumbnailPath(mediaPath string) string

func IsThumbnail

func IsThumbnail(imgPath string) bool

func LoadImage

func LoadImage(imgPath string) (model.Image, error)

LoadImage by: 1. ensuring there's a file on the path 2. determine encoding, width and height 3. encode to image.Image to allow working downstream

func SaveImage

func SaveImage(img image.Image, encoding string, path string) error

SaveImage by: 1. Opening file 2. Writing image using preferred encoding

Types

This section is empty.

Jump to

Keyboard shortcuts

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