resize

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddImageThumb

func AddImageThumb(media Media, size int, c Conf, wg *sync.WaitGroup, errChan chan<- error)

AddImageThumb creates a request to generate a single thumbnail from the original image.

func CreateOriginalFilePath

func CreateOriginalFilePath(path string, c Conf) string

CreateOriginalFilePath creates a string of the absolute path of the original media.

func CreateSaveImageThumb

func CreateSaveImageThumb(path string, media Media, size int, c Conf) ([]byte, error)

CreateSaveImageThumb opens the original file for image media types.

func CreateSaveVideoThumb

func CreateSaveVideoThumb(path string, media Media, size int, c Conf) ([]byte, error)

CreateSaveVideoThumb saves and returns a thumbnail for video media types.

func CreateTempDir

func CreateTempDir() (string, error)

CreateTempDir creates a temporary directory and returns its path

func CreateThumbFilePath

func CreateThumbFilePath(hash uint32, size int, c Conf) string

createThumbFilePath creates a string of the path where the thumb will live.

func CreateThumbFromDisk

func CreateThumbFromDisk(hash uint32, size int, c Conf) ([]byte, error)

CreateThumbFromDisk checks for an existing thumbnail in the cache directory. If it does not exist, a new thumbnail is created and saved.

func CreateVideoThumb

func CreateVideoThumb(path string) (io.Reader, error)

CreateVideoThumb creates a thumbnail for video media types.

func DecodeImage

func DecodeImage(path string) (image.Image, error)

func GenerateSingleThumb

func GenerateSingleThumb(path string, media Media, size int, c Conf) ([]byte, error)

GenerateSingleThumb serves a generated thumbnail from the original media.

func GetFFMPEGThumb

func GetFFMPEGThumb(video string, frameNum int) (io.Reader, error)

GetFFMPEGThumb serves a frame from a video.

func GetThumbFromResizeService

func GetThumbFromResizeService(media Media, size int, c Conf) ([]byte, error)

GetThumbFromResizeService requests a thumbnail from the resize service, serves the response, and then saves it to disk.

func HandleResize

func HandleResize(regenThumb bool, media Media, c Conf) (int, error)

HandleResize coordinates the parallel (go routine) generation of all non-existing thumbnails.

func HandleThumb

func HandleThumb(hash uint32, size int, c Conf) ([]byte, error)

HandleThumb determines whether to request a thumb from the resize service or check for one on disk.

func ResizeImageUpload

func ResizeImageUpload(w http.ResponseWriter, r *http.Request, c Conf) error

ResizeImageUpload accepts an image via POST, resizes it based on the size query param, and serves the resulting image.

func SafeImageOperation

func SafeImageOperation(operation func() ([]byte, error)) (file []byte, err error)

SafeImageOperation executes an image operation function and recovers from panics

func SaveImageToDisk

func SaveImageToDisk(path string, image image.Image, c Conf) error

SaveImageToDisk saves an image to disk at a specified location after confirming the dir exists.

Types

type Conf

type Conf = types.Conf

type Media

type Media = types.Media

Jump to

Keyboard shortcuts

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