Documentation ¶
Index ¶
- Constants
- Variables
- func AddBackgroundColor(img image.Image, clr color.Color) draw.Image
- func AddBackgroundWhite(img image.Image) image.Image
- func AddBorder(img draw.Image, clr color.Color, width uint) draw.Image
- func AddBorderAverageColor(img image.Image, width uint) image.Image
- func Aspect(width, height int) float64
- func BuildGifAnimationSimple(src *gif.GIF, delay int, imgs []image.Image, f ToPalettedFunc) *gif.GIF
- func BuildGifAnimationSimpleRead(src *gif.GIF, delay int, names []string, f ToPalettedFunc, consistentSize bool) (*gif.GIF, error)
- func BytesJPEG(img image.Image, opt *JPEGEncodeOptions) ([]byte, error)
- func ColsFilteredColor(img image.Image, c ...color.Color) []int
- func Crop(src image.Image, retain image.Rectangle) image.Image
- func CropX(src image.Image, width uint, align string) image.Image
- func CropY(src image.Image, height uint, align string) image.Image
- func ImageAspect(img image.Image) float64
- func ImageColors(img image.Image) [][]color.Color
- func ImageToPaletted(src image.Image, p color.Palette) *image.Paletted
- func ImageToPalettedPlan9(src image.Image) *image.Paletted
- func ImageToPalettedWebSafe(src image.Image) *image.Paletted
- func ImageToRGBA(src image.Image) *image.RGBA
- func IsImageExt(imagePath string) bool
- func IsNilOrEmpty(img image.Image) bool
- func JPEGMarker(b byte) []byte
- func MergeXRGBA(imgs []image.Image) image.Image
- func MergeXSameY(images []image.Image, larger bool) image.Image
- func MergeXSameYRead(locations []string, larger bool) (image.Image, error)
- func MergeYSameX(images []image.Image, larger bool) image.Image
- func MergeYSameXRead(locations []string, larger bool) (image.Image, error)
- func NegativeOffset(width, height, offset uint) image.Point
- func NewRGBAColor(rect image.Rectangle, clr color.RGBA) *image.RGBA
- func NewRGBATransparent(rect image.Rectangle) *image.RGBA
- func NewRGBAWhite(rect image.Rectangle) *image.RGBA
- func Overlay(src, overlay image.Image, offset image.Point) image.Image
- func OverlayMore(src, overlay image.Image, overlayLocation string, padX, padY int) image.Image
- func OverlayOffset(src, overlay image.Rectangle, overlayLocation string, padX, padY int) image.Point
- func PaintBorder(img draw.Image, clr color.Color, width uint)
- func PaintColor(img draw.Image, clr color.Color, area image.Rectangle)
- func ParseScaler(rawInterpolation string) (draw.Scaler, error)
- func ReadDirJPEGFiles(dir string, rx *regexp.Regexp) (osutil.DirEntries, error)
- func ReadImage(location string) (image.Image, string, error)
- func ReadImageDimensions(imagePath string) (int, int, error)
- func ReadImageFile(filename string) (image.Image, string, error)
- func ReadImageHTTP(imageURL string) (image.Image, string, error)
- func ReadImages(locations []string) ([]image.Image, error)
- func RectangleBorderXMax(rect image.Rectangle, pixels uint) image.Rectangle
- func RectangleBorderXMin(rect image.Rectangle, pixels uint) image.Rectangle
- func RectangleBorderYMax(rect image.Rectangle, pixels uint) image.Rectangle
- func RectangleBorderYMin(rect image.Rectangle, pixels uint) image.Rectangle
- func RectanglePixelCount(r image.Rectangle) int
- func Resize(width, height uint, src image.Image, scale draw.Scaler) image.Image
- func ResizeFileJPEG(inputFile, outputFile string, outputWidth, outputHeight uint, ...) error
- func ResizeMax(maxWidth, maxHeight uint, src image.Image, scale draw.Scaler) image.Image
- func ResizeMaxDimension(maxSide uint, src image.Image, scale draw.Scaler) image.Image
- func ResizeMin(minWidth, minHeight uint, src image.Image, scale draw.Scaler) image.Image
- func ResizeSameX(images []image.Image, larger bool) []image.Image
- func ResizeSameY(images []image.Image, larger bool) []image.Image
- func RowsFilteredColor(img image.Image, c color.Color, cmore ...color.Color) []int
- func Scale(src image.Image, rect image.Rectangle, scale draw.Scaler) image.Image
- func ScalerBest() draw.Scaler
- func ScalerDefault() draw.Scaler
- func SliceXY(images []image.Image, maxIdx int) (minX, maxX, minY, maxY, sumX, sumY int)
- func Square(src image.Image) image.Image
- func SquareLarger(src image.Image, bgcolor color.Color) image.Image
- func WriteFileGIF(filename string, img *gif.GIF) error
- func WriteFileJPEG(filename string, img image.Image, opt *JPEGEncodeOptions) error
- func WriteFilePNG(filename string, img image.Image) error
- func WriteJPEG(w io.Writer, img image.Image, opt *JPEGEncodeOptions) error
- type ImageMeta
- type ImageMetaSet
- func (ims *ImageMetaSet) CloseFilesAll() error
- func (ims *ImageMetaSet) Images() []image.Image
- func (ims *ImageMetaSet) MaxX() int
- func (ims *ImageMetaSet) MaxY() int
- func (ims *ImageMetaSet) Stats() ImagesStats
- func (ims *ImageMetaSet) SumX(maxIndexInclusive int) int
- func (ims *ImageMetaSet) SumY(maxIndexInclusive int) int
- type Images
- func (imgs Images) ConsistentSize(scale draw.Scaler, yAlign string)
- func (imgs Images) Dimensions() []image.Point
- func (imgs Images) DxMax() int
- func (imgs Images) DxMin() int
- func (imgs Images) DxSum(maxIndexInclusive int) int
- func (imgs Images) Dxs() []int
- func (imgs Images) DyMax() int
- func (imgs Images) DyMin() int
- func (imgs Images) DySum(maxIndexInclusive int) int
- func (imgs Images) Dys() []int
- func (imgs Images) Stats() ImagesStats
- type ImagesStats
- type JPEGEncodeOptions
- type Matrix
- func (matrix Matrix) AddBackgroundColor(clr color.Color)
- func (matrix Matrix) AddBackgroundColorHex(hexcolor string) error
- func (matrix Matrix) Dimensions() [][]image.Point
- func (matrix Matrix) DxSumMax() int
- func (matrix Matrix) DxSumMin() int
- func (matrix Matrix) Merge(largerX, largerY bool) image.Image
- type ToPalettedFunc
Constants ¶
const ( AlignTop = "top" AlignCenter = "center" AlignBottom = "bottom" AlignLeft = "left" AlignRight = "right" )
const ( AlgNearestNeighbor = "nearestneighbor" AlgApproxBiLinear = "approxbilinear" AlgBiLinear = "bilinear" AlgCatmullRom = "catmullrom" )
const ( LocUpper = "upper" LocMiddle = "middle" LocLower = "lower" LocLeft = "left" LocCenter = "center" LocRight = "right" LocUpperLeft = "upperleft" LocUpperRight = "upperright" LocLowerLeft = "lowerleft" LocLowerRight = "lowerright" )
const ( FileExtensionWebp = ".webp" FormatNameJPG = "jpeg" FormatNamePNG = "png" FormatNameWEBP = "webp" )
const ( JPEGExt = ".jpeg" JPEGExtJPG = ".jpg" JPEGQualityDefault = jpeg.DefaultQuality // 75 JPEGQualityMax = 100 JPEGQualityMin = 1 JPEGMarkerPrefix = 0xff JPEGMarkerExif = 0xe1 JPEGMarkerSOI = 0xd8 )
Variables ¶
var RxFileExtensionJPG = regexp.MustCompile(`(?i)^.*\.*jpe?g$`)
Functions ¶
func AddBackgroundColor ¶
AddBackgroundColor adds a background of `color.Color` to an image. It is is useful when the image has a transparent background. Use `colornames` for more colors, e.g. `colornames.Blue`. This returns a `draw.Image` so it can be used as an input to `draw.Draw()`.
func AddBackgroundWhite ¶
AddBackgroundWhite adds a white background which is usable when the image has a transparent background.
func AddBorder ¶ added in v0.35.7
AddBorder adds a border to a `draw.Image`. If you have an `image.Image`, first convert it with `ImageToRGBA(img)`.
func AddBorderAverageColor ¶ added in v0.49.0
func BuildGifAnimationSimple ¶ added in v0.36.0
func BuildGifAnimationSimple(src *gif.GIF, delay int, imgs []image.Image, f ToPalettedFunc) *gif.GIF
BuildGifAnimationSimple assembles a set of images in an animated GIF file. Set `delay` to `0`.
func BuildGifAnimationSimpleRead ¶ added in v0.37.0
func BytesJPEG ¶ added in v0.47.0
func BytesJPEG(img image.Image, opt *JPEGEncodeOptions) ([]byte, error)
func ColsFilteredColor ¶ added in v0.33.3
func ImageAspect ¶
func ImageColors ¶ added in v0.33.5
ImageColors returns colors for an image covering the pixels described in `image.Rectangle`: https://pkg.go.dev/image#Rectangle
func ImageToPaletted ¶ added in v0.36.0
func ImageToPalettedPlan9 ¶ added in v0.36.0
ImageToPalettedPlan9 converts an image to `*image.Paletted`. See the go implementation here: https://github.com/golang/go/blob/master/src/image/gif/writer.go
func ImageToPalettedWebSafe ¶ added in v0.36.5
ImageToPalettedWebSafe uses the 216 color palete created by Netscape. See more here: https://en.wikipedia.org/wiki/Web_colors#Web-safe_colors
func IsImageExt ¶
func IsNilOrEmpty ¶
func JPEGMarker ¶ added in v0.49.0
func MergeXRGBA ¶ added in v0.36.5
MergeXRGBA 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 NegativeOffset ¶
func OverlayMore ¶ added in v0.35.6
func OverlayOffset ¶ added in v0.35.7
func PaintBorder ¶ added in v0.35.7
PaintBorder colorizes a border of size `width` in the existing canvas, overwriting any colors in that space.
func PaintColor ¶ added in v0.35.7
func ReadDirJPEGFiles ¶ added in v0.49.0
func ReadImageHTTP ¶ added in v0.37.1
func RectangleBorderXMax ¶
func RectangleBorderXMin ¶
func RectangleBorderYMax ¶
func RectangleBorderYMin ¶
func RectanglePixelCount ¶ added in v0.35.1
func Resize ¶
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 ResizeFileJPEG ¶
func ResizeFileJPEG(inputFile, outputFile string, outputWidth, outputHeight uint, opt *JPEGEncodeOptions) error
func ResizeMax ¶
ResizeMax resizes an image to maximum dimensions. To resize to a maximum of 800 pixels width, the following can be used: `ResizeMax(800, 0, img, nil)`.
func ResizeMaxDimension ¶
func ResizeMin ¶
ResizeMin resizes an image to minimum dimensions. To resize to a minimum of 800 pixels width, the following can be used: `ResizeMin(800, 0, img, nil)`.
func RowsFilteredColor ¶ added in v0.33.2
func Scale ¶
Scale will resize the image to the provided rectangle using the provided interpolation function.
func ScalerBest ¶
func ScalerDefault ¶
ScalerDefault returns a general best results interpolation algorithm. See more here https://blog.codinghorror.com/better-image-resizing/ , https://support.esri.com/en/technical-article/000005606 , https://stackoverflow.com/questions/384991/what-is-the-best-image-downscaling-algorithm-quality-wise/6171860 .
func Square ¶
Square returns an image that is cropped to where the height and weight are equal to the smaller of the source image.
func SquareLarger ¶ added in v0.35.5
SquareLarger returns an image that is cropped to where the height and weight are equal to the larger of the source image.
func WriteFileJPEG ¶
func WriteFileJPEG(filename string, img image.Image, opt *JPEGEncodeOptions) error
Types ¶
type ImageMeta ¶
func NewImageMeta ¶ added in v0.35.0
func (*ImageMeta) ColorAverage ¶ added in v0.33.2
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) Images ¶ added in v0.37.8
func (ims *ImageMetaSet) Images() []image.Image
func (*ImageMetaSet) MaxX ¶
func (ims *ImageMetaSet) MaxX() int
func (*ImageMetaSet) MaxY ¶
func (ims *ImageMetaSet) MaxY() int
func (*ImageMetaSet) Stats ¶
func (ims *ImageMetaSet) Stats() ImagesStats
func (*ImageMetaSet) SumX ¶
func (ims *ImageMetaSet) SumX(maxIndexInclusive int) int
func (*ImageMetaSet) SumY ¶
func (ims *ImageMetaSet) SumY(maxIndexInclusive int) int
type Images ¶ added in v0.36.5
func (Images) ConsistentSize ¶ added in v0.36.5
ConsistentSize resizes and crops the images so that they have all the same size. It prioritize resizing images to max Dx and then cropping Dy so they are consistent.
func (Images) Dimensions ¶ added in v0.37.8
func (Images) DxSum ¶ added in v0.36.5
DxSum returns the sum of widths up to and including `maxIndexInclusive`. Use a negative value for `maxIndexInclusive` to include all elements.
func (Images) DySum ¶ added in v0.36.5
DySum returns the sum of heights up to and including `maxIndexInclusive`. Use a negative value for `maxIndexInclusive` to include all elements.
func (Images) Stats ¶ added in v0.36.5
func (imgs Images) Stats() ImagesStats
type ImagesStats ¶ added in v0.36.5
type JPEGEncodeOptions ¶ added in v0.49.0
type JPEGEncodeOptions struct { Options *jpeg.Options Exif []byte ReadFilenameRegexp *regexp.Regexp WriteExtension string }
func (JPEGEncodeOptions) ReadFilenameRegexpOrDefault ¶ added in v0.49.0
func (opts JPEGEncodeOptions) ReadFilenameRegexpOrDefault() *regexp.Regexp
func (JPEGEncodeOptions) WriteExtensionOrDefault ¶ added in v0.49.0
func (opts JPEGEncodeOptions) WriteExtensionOrDefault() string
type Matrix ¶
func MatrixRead ¶
func (Matrix) AddBackgroundColor ¶
AddBackgroundColor adds a background of `color.Color` to the images. It is is useful when the image has a transparent background. Use `colornames` for more colors, e.g. `colornames.Blue`.