imgutil

package
v0.0.0-...-2c87074 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Unlicense Imports: 9 Imported by: 15

Documentation

Overview

Package imgutil implements some image utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorEq

func ColorEq(c1, c2 color.Color) bool

ColorEq returns true if the colors c1 and c2 are equal, and false otherwise.

func Equal

func Equal(img1, img2 image.Image) bool

Equal returns true if the images img1 and img2 are equal, and false otherwise.

func NewSubImage

func NewSubImage(src image.Image, bounds image.Rectangle) image.Image

NewSubImage returns a subimage of the given source image based on the specified bounds.

func ReadFile

func ReadFile(imgPath string) (img image.Image, err error)

ReadFile reads an image file (gif, jpeg or png) specified by imgPath and returns it as an image.Image.

func WriteBMP

func WriteBMP(imgPath string, img image.Image) (err error)

WriteBMP writes the image data to a BMP file specified by imgPath. WriteBMP creates the named file using mode 0666 (before umask), truncating it if it already exists

func WriteFile

func WriteFile(imgPath string, img image.Image) (err error)

WriteFile writes the image data to a PNG file specified by imgPath. WriteFile creates the named file using mode 0666 (before umask), truncating it if it already exists.

func WriteJPEG

func WriteJPEG(imgPath string, img image.Image, quality int) (err error)

WriteJPEG writes the image data to a JPEG file specified by imgPath. writeJPEG creates the named file using mode 0666 (before umask), truncating it if it already exists. The quality of the output image is within the range [1, 100]; higher is better.

Types

type SubImager

type SubImager interface {
	image.Image
	// SubImage returns an image representing the portion of the image visible
	// through r. The returned value shares pixels with the original image.
	SubImage(r image.Rectangle) image.Image
}

SubImager is an interface that extends the basic image.Image interface with the SubImage method.

func SubFallback

func SubFallback(img image.Image) SubImager

SubFallback returns the provided image.Image as a SubImager. It provides a fallback for images missing the SubImage method.

Jump to

Keyboard shortcuts

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