images

package
v1.1.27 Latest Latest
Warning

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

Go to latest
Published: May 6, 2021 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package images generate thumbnails and converts between image formats.

Index

Constants

View Source
const (
	WebpMaxSize = 16383
)

Variables

View Source
var (
	ErrFormat = errors.New("unsupported image format")
	ErrViper  = errors.New("viper directory locations cannot be read")
)

Functions

func Duplicate

func Duplicate(filename, suffix string) (name string, err error)

Duplicate an image file and appends suffix to its name.

func Fix

func Fix(simulate bool) error

Fix generates any missing assets from downloads that are images.

func Generate

func Generate(src, id string, remove bool) error

Generate a collection of site images.

func Info

func Info(name string) (width, height int, format string, err error)

Info returns the image metadata.

func Move

func Move(src, dest string) error

Move a file from the source location to the destination. This is used in situations where os.rename() fails due to multiple partitions.

func NewExt

func NewExt(name, ext string) string

NewExt replaces or appends the extension to a file name.

func ToPng

func ToPng(src, dest string, width, height int) (s string, err error)

ToPng converts any supported format to a compressed PNG image. helpful: https://www.programming-books.io/essential/go/images-png-jpeg-bmp-tiff-webp-vp8-gif-c84a45304ec3498081c67aa1ea0d9c49

func ToThumb

func ToThumb(src, dest string, sizeSquared int) (s string, err error)

ToThumb creates a thumb from an image that is pixel squared in size.

func ToWebp

func ToWebp(src, dest string, vendorTempDir bool) (s string, err error)

ToWebp converts any supported format to a WebP image using a 3rd party library. Input format can be either PNG, JPEG, TIFF, WebP or raw Y'CbCr samples.

func WebPCalc added in v1.1.27

func WebPCalc(width, height int) (w, h int)

WebPCalc calculates the largest permitted sizes for a valid WebP crop.

func Width

func Width(name string) (width int, err error)

Width returns the image width in pixels.

Types

This section is empty.

Jump to

Keyboard shortcuts

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