images

package
v1.11.13 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package images generate thumbnails and converts these between image formats.

Index

Constants

View Source
const (
	WebpMaxSize int = 16383 // WebpMaxSize is the maximum pixel dimension of an webp image.

)

Variables

View Source
var ErrFormat = errors.New("unsupported image format")

Functions

func Copy added in v1.11.0

func Copy(dest, src string) error

Copy a file from the source location to the destination.

func Duplicate

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

Duplicate an image file and appends the suffix to its name.

func Fix

func Fix(db *sql.DB, w io.Writer, cfg conf.Config) error

Fix generates any missing assets from downloads that are images.

func Generate

func Generate(w io.Writer, cfg conf.Config, src, id string, remove bool) error

Generate a collection of site images.

func Info

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

Info returns the image metadata.

func Libraries added in v1.11.0

func Libraries(w io.Writer, src, pngDest string, remove bool) error

func Move

func Move(dest, src 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 ReplaceExt added in v1.11.0

func ReplaceExt(ext, name string) string

ReplaceExt replaces or appends the extension to a file name.

func ToPNG added in v1.11.0

func ToPNG(src, dest string, width, height int) (string, 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) (string, error)

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

func ToWebp

func ToWebp(w io.Writer, src, dest string, vendorTempDir bool) (string, error)

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

func WebPCalc

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) (int, error)

Width returns the image width in pixels.

Types

This section is empty.

Directories

Path Synopsis
internal
file
Package file handles the images as files.
Package file handles the images as files.
imagemagick
Package imagemagick interacts with ImageMagick graphic programs.
Package imagemagick interacts with ImageMagick graphic programs.
netpbm
Package netpbm interacts with the netpdm graphics programs and programming library.
Package netpbm interacts with the netpdm graphics programs and programming library.

Jump to

Keyboard shortcuts

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