imageutil

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JPEGQualityDefault int = 80
	JPEGQualityMax     int = 100
)

Variables

This section is empty.

Functions

func AddBackgroundColor added in v1.2.0

func AddBackgroundColor(imgSrc image.Image, clr color.Color) image.Image

AddBackgroundColor adds a background of `color.Color` to an image. It is is useful when the image has a transparent background.

func AddBackgroundWhite

func AddBackgroundWhite(imgSrc image.Image) image.Image

AddBackgroundWhite adds a white background which is usable when the image has a transparent background.

func Aspect

func Aspect(width, height int) float64

func ImageAnyToRGBA added in v1.2.0

func ImageAnyToRGBA(src image.Image) *image.RGBA

func ImageAspect

func ImageAspect(img image.Image) float64

func ImageToRGBA added in v1.1.0

func ImageToRGBA(img image.Image) *image.RGBA

func ImageWithSetToRGBA added in v1.2.0

func ImageWithSetToRGBA(src ImageWithSet) *image.RGBA

func IsImageExt

func IsImageExt(imagePath string) bool

func MergeHorizontalRGBA

func MergeHorizontalRGBA(ims ImageMetaSet) image.Image

MergeHorizontalRGBA returns an image that is composed of non-overlapping imagers in ImageMetaSet. The code here is adapted from https://stackoverflow.com/a/35965499/1908967

func NRGBAtoRGBA added in v1.1.0

func NRGBAtoRGBA(imgNRGBA *image.NRGBA) *image.RGBA

func NegativeOffset added in v1.1.0

func NegativeOffset(width, height, offset uint) image.Point

func OverlayCenterYLeftAlign

func OverlayCenterYLeftAlign(imgBg, imgOver image.Image) image.Image

func PaintBorderRGBA added in v1.1.0

func PaintBorderRGBA(img *image.RGBA, clr color.RGBA, width uint)

func PaintColorRGBA added in v1.1.0

func PaintColorRGBA(img *image.RGBA, clr color.RGBA)

func PaintColorRGBARectangle added in v1.1.0

func PaintColorRGBARectangle(img *image.RGBA, clr color.RGBA, rectNew image.Rectangle)

func ParseScaler added in v1.1.0

func ParseScaler(rawInterpolation string) (draw.Scaler, error)

func ReadImageAny added in v1.1.0

func ReadImageAny(s string) (image.Image, string, error)

func ReadImageDimensions

func ReadImageDimensions(imagePath string) (int, int, error)

func ReadImageFile added in v1.1.0

func ReadImageFile(filename string) (image.Image, string, error)

func ReadImageHttp added in v1.1.0

func ReadImageHttp(imageUrl string) (image.Image, string, error)

func RectangleBorderXMax added in v1.1.0

func RectangleBorderXMax(rect image.Rectangle, pixels uint) image.Rectangle

func RectangleBorderXMin added in v1.1.0

func RectangleBorderXMin(rect image.Rectangle, pixels uint) image.Rectangle

func RectangleBorderYMax added in v1.1.0

func RectangleBorderYMax(rect image.Rectangle, pixels uint) image.Rectangle

func RectangleBorderYMin added in v1.1.0

func RectangleBorderYMin(rect image.Rectangle, pixels uint) image.Rectangle

func Resize

func Resize(width, height uint, src image.Image, scale draw.Scaler) image.Image

Resize scales an image to the provided size units. Use a 0 to scale the aspect ratio. See gitub.com/nfnt/resize for Lanczos3, etc. https://github.com/nfnt/resize .

func ResizeMaxDimension added in v1.1.0

func ResizeMaxDimension(maxSide uint, src image.Image, scale draw.Scaler) image.Image

func Scale

func Scale(src image.Image, rect image.Rectangle, scale draw.Scaler) image.Image

Scale will resize the image to the provided rectangle using the provided interpolation function.

func ScalerBest added in v1.1.0

func ScalerBest() draw.Scaler

func Square added in v1.1.0

func Square(src image.Image) image.Image

func WriteFileJPEG

func WriteFileJPEG(filename string, img image.Image, quality int) error

func WriteFilePNG

func WriteFilePNG(filename string, img image.Image) error

func YCbCrToRGBA added in v1.1.0

func YCbCrToRGBA(src *image.YCbCr) *image.RGBA

Types

type ImageMeta

type ImageMeta struct {
	File       *os.File
	FormatName string
	Image      image.Image
}

type ImageMetaSet

type ImageMetaSet struct {
	ImageMetas []ImageMeta
}

func NewImageSetFiles

func NewImageSetFiles(filenames []string) (ImageMetaSet, error)

func (*ImageMetaSet) CloseFilesAll

func (ims *ImageMetaSet) CloseFilesAll() error

func (*ImageMetaSet) MaxX

func (ims *ImageMetaSet) MaxX() int

func (*ImageMetaSet) MaxY

func (ims *ImageMetaSet) MaxY() int

func (*ImageMetaSet) Stats

func (ims *ImageMetaSet) Stats() ImageStatsMulti

func (*ImageMetaSet) SumX

func (ims *ImageMetaSet) SumX(maxIndexInclusive int) int

func (*ImageMetaSet) SumY

func (ims *ImageMetaSet) SumY(maxIndexInclusive int) int

type ImageStatsMulti

type ImageStatsMulti struct {
	MaxX int
	SumX int
	MaxY int
	SumY int
}

type ImageWithSet added in v1.2.0

type ImageWithSet interface {
	// ColorModel returns the Image's color model.
	ColorModel() color.Model
	// Bounds returns the domain for which At can return non-zero color.
	// The bounds do not necessarily contain the point (0, 0).
	Bounds() image.Rectangle
	// At returns the color of the pixel at (x, y).
	// At(Bounds().Min.X, Bounds().Min.Y) returns the upper-left pixel of the grid.
	// At(Bounds().Max.X-1, Bounds().Max.Y-1) returns the lower-right one.
	At(x, y int) color.Color
	Set(x, y int, c color.Color)
}

Jump to

Keyboard shortcuts

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