vips

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2021 License: MIT Imports: 8 Imported by: 0

README

Go Vips

Go Vips is a go bind to libvips C API.

Install

Check if pkg-config is able to find the right libvips include:

pkg-config --cflags --libs vips  

Package 'libffi', required by 'gobject-2.0', not found

# optional, use you libffi lib path  
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"  

Per the security update https://groups.google.com/forum/#!topic/golang-announce/X7N1mvntnoU you may need whitelist the -Xpreprocessor flag in your environment.

export CGO_CFLAGS_ALLOW='-Xpreprocessor'  

examples

func main() {
	img := vips.NewFromFile("./images/Landscape_2.jpg")
	wm := vips.NewFromFile("./images/away.webp")

	err := wm.ThumbnailImage(200)
	if err != nil {
		panic(err)
	}

	err = wm.Resize(float64(img.Width()) / float64(wm.Width()))
	if err != nil {
		panic(err)
	}

	err = wm.Rotate(30)
	if err != nil {
		panic(err)
	}

	err = wm.Replicate(img.Width()/wm.Width()+1, img.Height()/wm.Height()+1)
	if err != nil {
		panic(err)
	}
	img.Replicate(2, 2)

	fmt.Println(img.Height(), img.Width())

	imgCopy, err := img.Copy()
	if err != nil {
		panic(err)
	}
	fmt.Println(imgCopy.Width())

	err = img.Save2file("out.png")
	if err != nil {
		panic(err)
	}
}

Features

conversion
  • Copy: Copy an image, optionally modifying the header.
  • Replicate: repeats an image many times.
  • Gravity: place in within an image of size width by height at a certain gravity.
  • Composite2: composite overlay on top of base with mode .
  • GetAngle: examine the metadata on im and return the VipsAngle
  • AutoRot: look at the image metadata and rotate the image to make it upright.
  • Embed: Embed *Image within an image of size width by height at position x , y .
  • ExtractArea: extract an area from an image. The area must fit within *Image.
  • Crop: Crop a synonym for ExtractArea
  • Flip: Flip an image left-right or up-down.
  • Grid: Grid chop a tall thin image up into a set of tiles, lay the tiles out in a grid.
  • Scale: Scale search the image for the maximum and minimum value
  • SubSample: SubSample an image by an integer fraction. This is fast, nearest-neighbour shrink.
  • Zoom: Zoom an image by repeating pixels. This is fast nearest-neighbour zoom.
  • Wrap: Wrap slice an image up and move the segments
  • ExtractBand: SmartCrop crop an image down to a specified width and height by removing boring parts.
create
  • Black: Black make a black unsigned char image of a specified size.
  • Xyz: Xyz Create a two-band uint32 image where the elements in the first band have the value of their x coordinate and elements in the second band have their y coordinate.
  • Grey: Grey create a one-band float image with the left-most column zero and the right-most 1.
  • GaussMat: GaussMat Creates a circularly symmetric Gaussian image of radius sigma.
  • LogMat: LogMat creates a circularly symmetric Laplacian of Gaussian mask of radius sigma.
  • Text: Text draw the string text to an image.
  • GaussNoise: GaussNoise make a one band float image of gaussian noise with the specified distribution.
  • Eye: Eye create a test pattern with increasing spatial frequence in X and amplitude in Y.
  • Sines: Sines creates a float one band image of the a sine waveform in two dimensions.
  • Zone: Zone create a one-band image of a zone plate.
  • Identity: Identity creates an identity lookup table.
  • BuildLut: BuildLut this operation builds a lookup table from a set of points.
  • InvertLut: InvertLut given a mask of target values and real values, generate a LUT which will map reals to targets.
  • ToneLut: ToneLut generates a tone curve for the adjustment of image levels.
  • MaskIdeal: MaskIdeal Make an ideal high- or low-pass filter.
  • MaskIdealRing: MaskIdealRing make an ideal ring-pass or ring-reject filter.
  • MaskIdealBand: MaskIdealBand make an ideal band-pass or band-reject filter.
  • MaskButterWorth: MaskButterWorth make an butterworth high- or low-pass filter.
  • MaskButterWorthRing: MaskButterWorthRing Make a butterworth ring-pass or ring-reject filter.
  • MaskButterWorthBand: MaskButterWorthBand make an butterworth band-pass or band-reject filter
  • MaskGaussian: MaskGaussian Make a gaussian high- or low-pass filter.
  • MaskGaussianRing: MaskGaussianRing Make a gaussian ring-pass or ring-reject filter.
  • MaskGaussianBand: MaskGaussianBand Make a gaussian band-pass or band-reject filter.
  • MaskFractal: MaskFractal operation should be used to create fractal images by filtering the power spectrum of Gaussian white noise
  • FractSurf: FractSurf Generate an image of size width by height and fractal dimension fractalDimension.
  • Worley: Worley create a one-band float image of Worley noise.
  • Perlin: Perlin create a one-band float image of Perlin noise.
draw
  • DrawRect: DrawRect paint pixels within left , top , width , height in image with ink.
  • DrawRect1: DrawRect1 as DrawRect, but just take a single float64 for ink.
  • DrawPoint: DrawPoint draw a single pixel at x, y.
  • DrawPoint1: DrawPoint1 as DrawPoint, but just take a single float64 for ink.
  • DrawImage: DrawImage draw sub on top of image at position x, y.
  • DrawMask: DrawMask draw mask on the image. mask is a monochrome 8-bit image with 0/255 for transparent or ink coloured points.
  • DrawMask1: DrawMask1 as DrawMask, but just take a single float64 for ink.
  • DrawLine: DrawLine draws a 1-pixel-wide line on an image.
  • DrawLine1: DrawLine1 as DrawLine, but just take a single double for ink.
  • DrawCircle: DrawCircle Draws a circle on image.
  • DrawCircle1: DrawCircle1 as DrawCircle, but just take a single double for ink.
  • DrawFlood: DrawFlood flood-fill image with ink, starting at position x , y.
  • DrawFlood1: DrawFlood1 as DrawFlood, but just take a single double for ink.
  • DrawSmudge: DrawSmudge smudge a section of image.
foreign_save
freqfilt
  • FwFFT: FwFFT transform an image to Fourier space.
  • InvFFT: InvFFT transform an image from Fourier space to real space.
  • FreqMult: FreqMult transformed to Fourier space, multipled with mask.
  • Spectrum: Spectrum make a displayable (ie. 8-bit unsigned int) power spectrum.
  • Phasecor: Phasecor convert the two input images to Fourier space, calculate phase-correlation, back to real space.
header
mosaicing
  • Merge: Merge joins two images left-right (with ref on the left) or up-down (with ref above) with a smooth seam.
  • Mosaic: Mosaic joins two images left-right (with ref on the left) or top-bottom (with ref above) given an approximate overlap.
  • Mosaic1: Mosaic1 This operation joins two images top-bottom (with sec on the right) or left-right (with sec at the bottom) given an approximate pair of tie-points.
  • Match: Match scale, rotate and translate sec so that the tie-points line up.
  • GlobalBalance: GlobalBalance can be used to remove contrast differences in an assembled mosaic.
  • ReMosaic: ReMosaic takes apart the mosaiced image in and rebuilds it, substituting images.
resample
  • Resize: Resize image
  • Rotate: Rotate image
  • Thumbnail: Thumbnail Make a thumbnail from a file
  • ThumbnailBuffer: ThumbnailBuffer Make a thumbnail from []byte
  • ThumbnailImage: ThumbnailImage Make a thumbnail from *Image
vip
  • DefaultInit: DefaultInit init vips by default
  • Init: Init starts up libvips
  • Shutdown: Shutdown drop caches and close plugins. Run with "--vips-leak" to do a leak check too.
  • LeakSet: LeakSet turn on or off vips leak checking
  • VersionString: VersionString get the VIPS version as a static string, including a build date and time.
  • Version: Version get the major, minor or micro library version, with flag values 0, 1 and 2.
  • Error: Error Get a pointer to the start of the error buffer as a C string.
vipsimage
  • New: New empty VipsImage
  • NewMemory: NewMemory creates a new VipsImage.
  • NewFromFile: NewFromFile opens filename for reading.
  • NewFromBuffer: NewFromBuffer loads an image from the formatted area of memory buf.
  • Height: Height return image height
  • Width: Width return image width
  • ProgressSet: ProgressSet ff set, vips will print messages about the progress of computation to stdout.
  • ImageSetProgress: ImageSetProgress vips signals evaluation progress via the “preeval”

Contributing

We appreciate your help!

Documentation

Index

Constants

View Source
const (
	// DirectionCentre centre
	DirectionCentre = CompassDirection(C.VIPS_COMPASS_DIRECTION_CENTRE)
	// DirectionNorth notrh
	DirectionNorth = CompassDirection(C.VIPS_COMPASS_DIRECTION_NORTH)
	// DirectionEast east
	DirectionEast = CompassDirection(C.VIPS_COMPASS_DIRECTION_EAST)
	// DirectionSouth south
	DirectionSouth = CompassDirection(C.VIPS_COMPASS_DIRECTION_SOUTH)
	// DirectionWest west
	DirectionWest = CompassDirection(C.VIPS_COMPASS_DIRECTION_WEST)
	// DirectionNorthEast north-east
	DirectionNorthEast = CompassDirection(C.VIPS_COMPASS_DIRECTION_NORTH_EAST)
	// DirectionSouthEast south-east
	DirectionSouthEast = CompassDirection(C.VIPS_COMPASS_DIRECTION_SOUTH_EAST)
	// DirectionSouthWest south-west
	DirectionSouthWest = CompassDirection(C.VIPS_COMPASS_DIRECTION_SOUTH_WEST)
	// DirectionNorthWest north-west
	DirectionNorthWest = CompassDirection(C.VIPS_COMPASS_DIRECTION_NORTH_WEST)
)
View Source
const (
	// BlendModeClear where the second object is drawn, the first is removed
	BlendModeClear = BlendMode(C.VIPS_BLEND_MODE_CLEAR)
	// BlendModeSource the second object is drawn as if nothing were below
	BlendModeSource = BlendMode(C.VIPS_BLEND_MODE_SOURCE)
	// BlendModeOver the image shows what you would expect if you held two semi-transparent slides on top of each other
	BlendModeOver = BlendMode(C.VIPS_BLEND_MODE_OVER)
	// BlendModeIn the first object is removed completely, the second is only drawn where the first was
	BlendModeIn = BlendMode(C.VIPS_BLEND_MODE_IN)
	// BlendModeOut the second is drawn only where the first isn't
	BlendModeOut = BlendMode(C.VIPS_BLEND_MODE_OUT)
	// BlendModeAtop this leaves the first object mostly intact, but mixes both objects in the overlapping area
	BlendModeAtop = BlendMode(C.VIPS_BLEND_MODE_ATOP)
	// BlendModeDest leaves the first object untouched, the second is discarded completely
	BlendModeDest = BlendMode(C.VIPS_BLEND_MODE_DEST)
	// BlendModeDestOver like OVER, but swaps the arguments
	BlendModeDestOver = BlendMode(C.VIPS_BLEND_MODE_DEST_OVER)
	// BlendModeDestIn like IN, but swaps the arguments
	BlendModeDestIn = BlendMode(C.VIPS_BLEND_MODE_DEST_IN)
	// BlendModeDestOut like OUT, but swaps the arguments
	BlendModeDestOut = BlendMode(C.VIPS_BLEND_MODE_DEST_OUT)
	// BlendModeDestAtop like ATOP, but swaps the arguments
	BlendModeDestAtop = BlendMode(C.VIPS_BLEND_MODE_DEST_ATOP)
	// BlendModeXor something like a difference operator
	BlendModeXor = BlendMode(C.VIPS_BLEND_MODE_XOR)
	// BlendModeAdd a bit like adding the two images
	BlendModeAdd = BlendMode(C.VIPS_BLEND_MODE_ADD)
	// BlendModeSaturate a bit like the darker of the two
	BlendModeSaturate = BlendMode(C.VIPS_BLEND_MODE_SATURATE)
	// BlendModeMultiply at least as dark as the darker of the two inputs
	BlendModeMultiply = BlendMode(C.VIPS_BLEND_MODE_MULTIPLY)
	// BlendModeScreen at least as light as the lighter of the inputs
	BlendModeScreen = BlendMode(C.VIPS_BLEND_MODE_SCREEN)
	// BlendModeOverlay multiplies or screens colors, depending on the lightness
	BlendModeOverlay = BlendMode(C.VIPS_BLEND_MODE_OVERLAY)
	// BlendModeDarken the darker of each component
	BlendModeDarken = BlendMode(C.VIPS_BLEND_MODE_DARKEN)
	// BlendModeLighten the lighter of each component
	BlendModeLighten = BlendMode(C.VIPS_BLEND_MODE_LIGHTEN)
	// BlendModeColourDodge brighten first by a factor second
	BlendModeColourDodge = BlendMode(C.VIPS_BLEND_MODE_COLOUR_DODGE)
	// BlendModeColourBurn darken first by a factor of second
	BlendModeColourBurn = BlendMode(C.VIPS_BLEND_MODE_COLOUR_BURN)
	// BlendModeHardLight multiply or screen, depending on lightness
	BlendModeHardLight = BlendMode(C.VIPS_BLEND_MODE_HARD_LIGHT)
	// BlendModeSoftLight darken or lighten, depending on lightness
	BlendModeSoftLight = BlendMode(C.VIPS_BLEND_MODE_SOFT_LIGHT)
	// BlendModeDifference difference of the two
	BlendModeDifference = BlendMode(C.VIPS_BLEND_MODE_DIFFERENCE)
	// BlendModeExclusion somewhat like DIFFERENCE, but lower-contrast
	BlendModeExclusion = BlendMode(C.VIPS_BLEND_MODE_EXCLUSION)
)
View Source
const (
	// AngleD0 no rotate
	AngleD0 = Angle(C.VIPS_ANGLE_D0)
	// AngleD90 90 degrees clockwise
	AngleD90 = Angle(C.VIPS_ANGLE_D90)
	// AngleD180 180 degree rotate
	AngleD180 = Angle(C.VIPS_ANGLE_D180)
	// AngleD270 90 degrees anti-clockwise
	AngleD270 = Angle(C.VIPS_ANGLE_D270)
)
View Source
const (
	// DirectionHorizontal left-right
	DirectionHorizontal = Direction(C.VIPS_DIRECTION_HORIZONTAL)
	// DirectionVertical top-bottom
	DirectionVertical = Direction(C.VIPS_DIRECTION_VERTICAL)
)

Variables

This section is empty.

Functions

func DefaultInit

func DefaultInit()

DefaultInit init vips by default

func Error

func Error() error

Error Get a pointer to the start of the error buffer as a C string. The string is owned by the error system and must not be freed.

func ForeignFindLoad

func ForeignFindLoad(filename string) string

ForeignFindLoad searches for an operation you could use to load filename. Any trailing options on filename are stripped and ignored.

func ForeignFindLoadBuffer

func ForeignFindLoadBuffer(data []byte) string

ForeignFindLoadBuffer searches for an operation you could use to load a memory buffer.

func Free

func Free(in *Image)

Free VipsImage

func Init

func Init() (err error)

Init starts up libvips

func LeakSet

func LeakSet(leak bool)

LeakSet turn on or off vips leak checking

func ProgressSet

func ProgressSet(progress bool)

ProgressSet ff set, vips will print messages about the progress of computation to stdout. This can also be enabled with the --vips-progress option, or by setting the environment variable VIPS_PROGRESS.

func Shutdown

func Shutdown()

Shutdown drop caches and close plugins. Run with "--vips-leak" to do a leak check too.

func Version

func Version(flag int) int

Version get the major, minor or micro library version, with flag values 0, 1 and 2.

func VersionString

func VersionString() string

VersionString get the VIPS version as a static string, including a build date and time. Do not free.

Types

type Angle

type Angle int

Angle Fixed rotate angles.

type BlendMode

type BlendMode int

BlendMode The various Porter-Duff and PDF blend modes. See vips_composite(), for example. The Cairo docs have a nice explanation of all the blend modes:

https://www.cairographics.org/operators The non-separable modes are not implemented.

type CompassDirection

type CompassDirection int

CompassDirection direction on a compass.

type Direction

type Direction int

Direction Operations like Flip() need to be told whether to flip left-right or top-bottom.

type Image

type Image struct {
	// contains filtered or unexported fields
}

Image wrap *C.VipsImage to go

func AnalyzeLoad

func AnalyzeLoad(filename string) (out *Image, err error)

AnalyzeLoad load an Analyze 6.0 file. If filename is "fred.img", this will look for an image header called "fred.hdr" and pixel data in "fred.img". You can also load "fred" or "fred.hdr".

func Black

func Black(width, height int) (out *Image, err error)

Black make a black unsigned char image of a specified size.

func CSVLoad

func CSVLoad(filename string) (out *Image, err error)

CSVLoad load a CSV (comma-separated values) file. The output image is always 1 band (monochrome), VIPS_FORMAT_DOUBLE. Use BandFold() to turn RGBRGBRGB mono images into colour iamges."fred.img". You can also load "fred" or "fred.hdr".

func Eye

func Eye(width, height int) (out *Image, err error)

Eye create a test pattern with increasing spatial frequence in X and amplitude in Y.

func FITSLoad

func FITSLoad(filename string) (out *Image, err error)

FITSLoad read a FITS image file into a VIPS image.

func FractSurf

func FractSurf(width, height int, fractalDimension float64) (out *Image, err error)

FractSurf Generate an image of size width by height and fractal dimension fractalDimension. The dimension should be between 2 and 3.

func GIFLoad

func GIFLoad(filename string) (out *Image, err error)

GIFLoad render a GIF file into a VIPS image. Rendering uses the librgif library and should be fast.

func GIFLoadBuffer

func GIFLoadBuffer(buf []byte) (out *Image, err error)

GIFLoadBuffer read a GIF-formatted memory block into a VIPS image. Exactly as GIFLoad, but read from a memory buffer.

func GaussMat

func GaussMat(sigma, minAmpl float64) (out *Image, err error)

GaussMat Creates a circularly symmetric Gaussian image of radius sigma. The size of the mask is determined by the variable minAmpl ; if for instance the value .1 is entered this means that the produced mask is clipped at values less than 10 percent of the maximum amplitude.

func GaussNoise

func GaussNoise(width, height int) (out *Image, err error)

GaussNoise make a one band float image of gaussian noise with the specified distribution. The noise distribution is created by averaging 12 random numbers with the appropriate weights.

func Grey

func Grey(width, height int) (out *Image, err error)

Grey create a one-band float image with the left-most column zero and the right-most 1. Intermediate pixels are a linear ramp.

func HEIFLoad

func HEIFLoad(filename string) (out *Image, err error)

HEIFLoad read a HEIF image file into a VIPS image.

func HEIFLoadBuffer

func HEIFLoadBuffer(buf []byte) (out *Image, err error)

HEIFLoadBuffer read a HEIF-formatted memory block into a VIPS image. Exactly as HEIFLoad, but read from a memory buffer.

func Identity

func Identity() (out *Image, err error)

Identity creates an identity lookup table. ie. one which will leave an image unchanged when applied with Maplut(). Each entry in the table has a value equal to its position.

func JPEGLoad

func JPEGLoad(filename string) (out *Image, err error)

JPEGLoad read a JPEG file into a VIPS image. It can read most 8-bit JPEG images, including CMYK and YCbCr.

func JPEGLoadBuffer

func JPEGLoadBuffer(buf []byte) (out *Image, err error)

JPEGLoadBuffer read a JPEG-formatted memory block into a VIPS image. Exactly as JPEGLoad, but read from a memory buffer.

func Load

func Load(filename string) (out *Image, err error)

Load read in a vips image.

func LogMat

func LogMat(sigma, minAmpl float64) (out *Image, err error)

LogMat creates a circularly symmetric Laplacian of Gaussian mask of radius sigma. The size of the mask is determined by the variable min_ampl ; if for instance the value .1 is entered this means that the produced mask is clipped at values within 10 persent of zero, and where the change between mask elements is less than 10%.

func MagickLoad

func MagickLoad(filename string) (out *Image, err error)

MagickLoad read in an image using libMagick, the ImageMagick library. This library can read more than 80 file formats, including SVG, BMP, EPS, DICOM and many others. The reader can handle any ImageMagick image, including the float and double formats. It will work with any quantum size, including HDR. Any metadata attached to the libMagick image is copied on to the VIPS image.

func MagickLoadBuffer

func MagickLoadBuffer(buf []byte) (out *Image, err error)

MagickLoadBuffer read a Magick-formatted memory block into a VIPS image. Exactly as MagickLoad, but read from a memory buffer.

func MaskButterWorth

func MaskButterWorth(width, height int, order, frequencyCutoff, amplitudeCutoff float64) (out *Image, err error)

MaskButterWorth make an butterworth high- or low-pass filter, that is, one with a variable, smooth transition positioned at frequency_cutoff , where frequency_cutoff is in range 0 - 1. The shape of the curve is controlled by order --- higher values give a sharper transition. See Gonzalez and Wintz, Digital Image Processing, 1987.

func MaskButterWorthBand

func MaskButterWorthBand(width, height int,
	order, frequencyCutoffX, frequencyCutoffY, radius, amplitudeCutoff float64) (out *Image, err error)

MaskButterWorthBand make an butterworth band-pass or band-reject filter, that is, one with a variable, smooth transition positioned at frequencyCutoffX, frequencyCutoffY , of radius radius . The shape of the curve is controlled by order --- higher values give a sharper transition. See Gonzalez and Wintz, Digital Image Processing, 1987.

func MaskButterWorthRing

func MaskButterWorthRing(width, height int, order, frequencyCutoff, amplitudeCutoff, ringWidth float64) (out *Image, err error)

MaskButterWorthRing Make a butterworth ring-pass or ring-reject filter, that is, one with a variable, smooth transition positioned at frequencyCutoff of width width , where frequencyCutoff is in the range 0 - 1. The shape of the curve is controlled by order --- higher values give a sharper transition. See Gonzalez and Wintz, Digital Image Processing, 1987.

func MaskFractal

func MaskFractal(width, height int, fractalDimension float64) (out *Image, err error)

MaskFractal operation should be used to create fractal images by filtering the power spectrum of Gaussian white noise. See GaussNoise().

func MaskGaussian

func MaskGaussian(width, height int, frequencyCutoff, amplitudeCutoff float64) (out *Image, err error)

MaskGaussian Make a gaussian high- or low-pass filter, that is, one with a variable, smooth transition positioned at frequencyCutoff .

func MaskGaussianBand

func MaskGaussianBand(width, height int, frequencyCutoffX, frequencyCutoffY, radius, amplitudeCutoff float64) (out *Image, err error)

MaskGaussianBand Make a gaussian band-pass or band-reject filter, that is, one with a variable, smooth transition positioned at frequencyCutoffX, frequencyCutoffY, of radius radius.

func MaskGaussianRing

func MaskGaussianRing(width, height int, frequencyCutoff, amplitudeCutoff, ringWidth float64) (out *Image, err error)

MaskGaussianRing Make a gaussian ring-pass or ring-reject filter, that is, one with a variable, smooth transition positioned at frequencyCutoff of width ringWidth .

func MaskIdeal

func MaskIdeal(width, height int, frequencyCutoff float64) (out *Image, err error)

MaskIdeal Make an ideal high- or low-pass filter, that is, one with a sharp cutoff positioned at frequencyCutoff , where frequencyCutoff is in the range 0 - 1.

func MaskIdealBand

func MaskIdealBand(width, height int, frequencyCutoffX, frequencyCutoffY, radius float64) (out *Image, err error)

MaskIdealBand make an ideal band-pass or band-reject filter, that is, one with a sharp cutoff around the point frequencyCutoffX, frequencyCutoffY of size radius .

func MaskIdealRing

func MaskIdealRing(width, height int, frequencyCutoff, ringWidth float64) (out *Image, err error)

MaskIdealRing make an ideal ring-pass or ring-reject filter, that is, one with a sharp ring positioned at frequency_cutoff of width width , where frequencyCutoff and width are expressed as the range 0 - 1.

func MatLoad

func MatLoad(filename string) (out *Image, err error)

MatLoad read a Matlab save file into a VIPS image.

func MatrixLoad

func MatrixLoad(filename string) (out *Image, err error)

MatrixLoad reads a matrix from a file.

func NIFTILoad

func NIFTILoad(filename string) (out *Image, err error)

NIFTILoad read a NIFTI image file into a VIPS image.

func New

func New() *Image

New empty VipsImage

func NewFromBuffer

func NewFromBuffer(buf []byte, optionString string) *Image

NewFromBuffer loads an image from the formatted area of memory buf.

func NewFromFile

func NewFromFile(filename string) (out *Image, err error)

NewFromFile opens filename for reading. It can load files in many image formats, including VIPS, TIFF, PNG, JPEG, FITS, Matlab, OpenEXR, CSV, WebP, Radiance, RAW, PPM and others.

func NewMemory

func NewMemory() *Image

NewMemory creates a new VipsImage. when written to, will create a memory image.

func OpenEXRLoad

func OpenEXRLoad(filename string) (out *Image, err error)

OpenEXRLoad read a OpenEXR file into a VIPS image.

func OpenSlideLoad

func OpenSlideLoad(filename string) (out *Image, err error)

OpenSlideLoad Read a virtual slide supported by the OpenSlide library into a VIPS image. OpenSlide supports images in Aperio, Hamamatsu, MIRAX, Sakura, Trestle, and Ventana formats.

func PDFLoad

func PDFLoad(filename string) (out *Image, err error)

PDFLoad read a PDF-formatted memory buffer into a VIPS image. Exactly as vips_pdfload(), but read from memory.

func PDFLoadBuffer

func PDFLoadBuffer(buf []byte) (out *Image, err error)

PDFLoadBuffer read a PDF-formatted memory block into a VIPS image. Exactly as PDFLoad, but read from a memory buffer.

func PNGLoad

func PNGLoad(filename string) (out *Image, err error)

PNGLoad read a PNG-formatted memory block into a VIPS image. It can read all png images, including 8- and 16-bit images, 1 and 3 channel, with and without an alpha channel.

func PNGLoadBuffer

func PNGLoadBuffer(buf []byte) (out *Image, err error)

PNGLoadBuffer read a PNG-formatted memory block into a VIPS image. Exactly as PNGLoad, but read from a memory buffer.

func PPMLoad

func PPMLoad(filename string) (out *Image, err error)

PPMLoad read a PPM/PBM/PGM/PFM file into a VIPS image.

func Perlin

func Perlin(width, height int) (out *Image, err error)

Perlin create a one-band float image of Perlin noise. See:

https://en.wikipedia.org/wiki/Perlin_noise

func RADLoad

func RADLoad(filename string) (out *Image, err error)

RADLoad read a Radiance (HDR) file into a VIPS image.

func RawLoad

func RawLoad(filename string, width, height, bands int) (out *Image, err error)

RawLoad mmaps the file, setting up out so that access to that image will read from the file.

func SVGLoad

func SVGLoad(filename string) (out *Image, err error)

SVGLoad render a SVG file into a VIPS image. Rendering uses the librsvg library and should be fast.

func SVGLoadBuffer

func SVGLoadBuffer(buf []byte) (out *Image, err error)

SVGLoadBuffer read a SVG-formatted memory block into a VIPS image. Exactly as SVGLoad, but read from a memory buffer.

func Sines

func Sines(width, height int) (out *Image, err error)

Sines creates a float one band image of the a sine waveform in two dimensions.

func TIFFLoad

func TIFFLoad(filename string) (out *Image, err error)

TIFFLoad read a TIFF file into a VIPS image. It is a full baseline TIFF 6 reader, with extensions for tiled images, multipage images, LAB colour space, pyramidal images and JPEG compression. including CMYK and YCbCr.

func TIFFLoadBuffer

func TIFFLoadBuffer(buf []byte) (out *Image, err error)

TIFFLoadBuffer read a TIFF-formatted memory block into a VIPS image. Exactly as TIFFLoad, but read from a memory buffer.

func Text

func Text(text string) (out *Image, err error)

Text draw the string text to an image. out is a one-band 8-bit unsigned char image, with 0 for no text and 255 for text. Values between are used for anti-aliasing.

func Thumbnail

func Thumbnail(filename string, width int) (out *Image, err error)

Thumbnail Make a thumbnail from a file

func ThumbnailBuffer

func ThumbnailBuffer(buf []byte, width int) (out *Image, err error)

ThumbnailBuffer Make a thumbnail from []byte

func ToneLut

func ToneLut() (out *Image, err error)

ToneLut generates a tone curve for the adjustment of image levels. It is mostly designed for adjusting the L* part of a LAB image in a way suitable for print work, but you can use it for other things too.

func WEBPLoad

func WEBPLoad(filename string) (out *Image, err error)

WEBPLoad read a WebP file into a VIPS image.

func WEBPLoadBuffer

func WEBPLoadBuffer(buf []byte) (out *Image, err error)

WEBPLoadBuffer read a WebP-formatted memory block into a VIPS image. Exactly as WEBPLoad, but read from a memory buffer.

func Worley

func Worley(width, height int) (out *Image, err error)

Worley create a one-band float image of Worley noise. See:

https://en.wikipedia.org/wiki/Worley_noise

func Xyz

func Xyz(width, height int) (out *Image, err error)

Xyz Create a two-band uint32 image where the elements in the first band have the value of their x coordinate and elements in the second band have their y coordinate.

You can make any image where the value of a pixel is a function of its (x, y) coordinate by combining this operator with the arithmetic operators.

func Zone

func Zone(width, height int) (out *Image, err error)

Zone create a one-band image of a zone plate.

func (*Image) AutoRot

func (th *Image) AutoRot() (err error)

AutoRot look at the image metadata and rotate the image to make it upright. Note:

vips only supports the four simple rotations, it does not support the various mirror modes. If the image is using one of these mirror modes, the image is not rotated and the VIPS_META_ORIENTATION tag is not removed.

func (*Image) BuildLut

func (th *Image) BuildLut() (err error)

BuildLut this operation builds a lookup table from a set of points. Intermediate values are generated by piecewise linear interpolation

func (*Image) CSVSave

func (th *Image) CSVSave(filename string) (err error)

CSVSave write a VIPS image to a file as CSV.

func (*Image) Composite

func (th *Image) Composite()

Composite ...

func (*Image) Composite2

func (th *Image) Composite2(overlay *Image, mode BlendMode, point image.Point) (err error)

Composite2 composite overlay on top of base with mode. See Composite.

func (*Image) Copy

func (th *Image) Copy() (out *Image, err error)

Copy an image, optionally modifying the header. VIPS copies images by copying pointers, so this operation is instant, even for very large images.

func (*Image) Crop

func (th *Image) Crop(left, top, width, height int) (err error)

Crop a synonym for ExtractArea.

func (*Image) DZSave

func (th *Image) DZSave(filename string) (err error)

DZSave save an image as a set of tiles at various resolutions. By default dzsave uses DeepZoom layout -- use layout to pick other conventions.

func (*Image) DrawCircle

func (th *Image) DrawCircle(ink []float64, cx, cy, radius int) (err error)

DrawCircle Draws a circle on image. If fill is TRUE then the circle is filled, otherwise a 1-pixel-wide perimeter is drawn.

func (*Image) DrawCircle1

func (th *Image) DrawCircle1(ink float64, cx, cy, radius int) (err error)

DrawCircle1 as DrawCircle, but just take a single double for ink.

func (*Image) DrawFlood

func (th *Image) DrawFlood(ink []float64, x, y int) (err error)

DrawFlood flood-fill image with ink, starting at position x , y. The filled area is bounded by pixels that are equal to the ink colour, in other words, it searches for pixels enclosed by an edge of ink .

func (*Image) DrawFlood1

func (th *Image) DrawFlood1(ink float64, x, y int) (err error)

DrawFlood1 as DrawFlood, but just take a single double for ink.

func (*Image) DrawImage

func (th *Image) DrawImage(sub *Image, x, y int) (err error)

DrawImage draw sub on top of image at position x, y.

func (*Image) DrawLine

func (th *Image) DrawLine(ink []float64, x1, y1, x2, y2 int) (err error)

DrawLine draws a 1-pixel-wide line on an image.

func (*Image) DrawLine1

func (th *Image) DrawLine1(ink float64, x1, y1, x2, y2 int) (err error)

DrawLine1 as DrawLine, but just take a single double for ink.

func (*Image) DrawMask

func (th *Image) DrawMask(ink []float64, mask *Image, x, y int) (err error)

DrawMask draw mask on the image. mask is a monochrome 8-bit image with 0/255 for transparent or ink coloured points. Intermediate values blend the ink with the pixel. Use with Text() to draw text on an image. Use in a DrawLine() subclass to draw an object along a line.

func (*Image) DrawMask1

func (th *Image) DrawMask1(ink float64, mask *Image, x, y int) (err error)

DrawMask1 as DrawMask, but just take a single float64 for ink.

func (*Image) DrawPoint

func (th *Image) DrawPoint(ink []float64, x, y int) (err error)

DrawPoint draw a single pixel at x, y.

func (*Image) DrawPoint1

func (th *Image) DrawPoint1(ink float64, x, y int) (err error)

DrawPoint1 as DrawPoint, but just take a single float64 for ink.

func (*Image) DrawRect

func (th *Image) DrawRect(ink []float64, left, top, width, height int) (err error)

DrawRect paint pixels within left , top , width , height in image with ink. If fill is zero, just paint a 1-pixel-wide outline.

func (*Image) DrawRect1

func (th *Image) DrawRect1(ink float64, left, top, width, height int) (err error)

DrawRect1 as DrawRect, but just take a single float64 for ink.

func (*Image) DrawSmudge

func (th *Image) DrawSmudge(left, top, width, height int) (err error)

DrawSmudge smudge a section of image. Each pixel in the area left , top , width , height is replaced by the average of the surrounding 3x3 pixels.

func (*Image) Embed

func (th *Image) Embed(x, y, width, height int) (err error)

Embed *Image within an image of size width by height at position x , y .

func (*Image) ExtractArea

func (th *Image) ExtractArea(left, top, width, height int) (err error)

ExtractArea extract an area from an image. The area must fit within *Image.

func (*Image) ExtractBand

func (th *Image) ExtractBand(band int) (err error)

ExtractBand extract a band or bands from an image. Extracting out of range is an error.

func (*Image) FITSSave

func (th *Image) FITSSave(filename string) (err error)

FITSSave write a VIPS image to a file as FITS.

func (*Image) Flip

func (th *Image) Flip(direction Direction) (err error)

Flip an image left-right or up-down.

func (*Image) FormatSizeof

func (th *Image) FormatSizeof()

FormatSizeof ...

func (*Image) Free

func (th *Image) Free()

Free Image

func (*Image) FreqMult

func (th *Image) FreqMult(mask *Image) (err error)

FreqMult transformed to Fourier space, multipled with mask, then transformed back to real space. If in is already a complex image, just multiply then inverse transform.

func (*Image) FwFFT

func (th *Image) FwFFT() (err error)

FwFFT transform an image to Fourier space. VIPS uses the fftw Fourier Transform library. If this library was not available when VIPS was configured, these functions will fail.

func (*Image) GlobalBalance

func (th *Image) GlobalBalance() (err error)

GlobalBalance can be used to remove contrast differences in an assembled mosaic.

func (*Image) Gravity

func (th *Image) Gravity(direction CompassDirection, width, height int) (err error)

Gravity place in within an image of size width by height at a certain gravity.

func (*Image) Grid

func (th *Image) Grid(tileHeight, across, down int) (err error)

Grid chop a tall thin image up into a set of tiles, lay the tiles out in a grid.

func (*Image) HEIFSave

func (th *Image) HEIFSave(filename string) (err error)

HEIFSave write a VIPS image to a file as HEIF.

func (*Image) HEIFSaveBuffer

func (th *Image) HEIFSaveBuffer() (buf []byte, size int, err error)

HEIFSaveBuffer as HEIFSave, but save to a memory buffer.

func (*Image) Height

func (th *Image) Height() int

Height return image height

func (*Image) ImageSetProgress

func (th *Image) ImageSetProgress(progress bool)

ImageSetProgress vips signals evaluation progress via the “preeval”, “eval” and “posteval” signals. Progress is signalled on the most-downstream image for which vips_image_set_progress() was called.

func (*Image) InvFFT

func (th *Image) InvFFT() (err error)

InvFFT transform an image from Fourier space to real space. The result is complex.

func (*Image) InvertLut

func (th *Image) InvertLut() (err error)

InvertLut given a mask of target values and real values, generate a LUT which will map reals to targets. Handy for linearising images from measurements of a colour chart. All values in [0,1]. Piecewise linear interpolation, extrapolate head and tail to 0 and 1.

func (*Image) JPEGSave

func (th *Image) JPEGSave(filename string) (err error)

JPEGSave write a VIPS image to a file as JPEG.

func (*Image) JPEGSaveBuffer

func (th *Image) JPEGSaveBuffer() (buf []byte, size int, err error)

JPEGSaveBuffer as JPEGSave, but save to a memory buffer.

func (*Image) JPEGSaveMime

func (th *Image) JPEGSaveMime() (err error)

JPEGSaveMime As JPEGSave, but save as a mime jpeg on stdout.

func (*Image) MagickSave

func (th *Image) MagickSave(filename string) (err error)

MagickSave write a VIPS image to a file as Magick.

func (*Image) MagickSaveBuffer

func (th *Image) MagickSaveBuffer() (buf []byte, size int, err error)

MagickSaveBuffer as MagickSave, but save to a memory buffer.

func (*Image) Match

func (th *Image) Match(sec *Image, xr1, yr1, xs1, ys1, xr2, yr2, xs2, ys2 int) (err error)

Match scale, rotate and translate sec so that the tie-points line up.

func (*Image) MatrixPrint

func (th *Image) MatrixPrint() (err error)

MatrixPrint print in to stdout in matrix format. See MatrixLoad for a description of the format.

func (*Image) MatrixSave

func (th *Image) MatrixSave(filename string) (err error)

MatrixSave write a VIPS image to a file as Matrix.

func (*Image) Merge

func (th *Image) Merge(sec *Image, direction Direction, dx, dy int) (err error)

Merge joins two images left-right (with ref on the left) or up-down (with ref above) with a smooth seam.

func (*Image) Mosaic

func (th *Image) Mosaic(sec *Image, direction Direction, xref, yref, xsec, ysec int) (err error)

Mosaic joins two images left-right (with ref on the left) or top-bottom (with ref above) given an approximate overlap.

func (*Image) Mosaic1

func (th *Image) Mosaic1(sec *Image, direction Direction, xr1, yr1, xs1, ys1, xr2, yr2, xs2, ys2 int) (err error)

Mosaic1 This operation joins two images top-bottom (with sec on the right) or left-right (with sec at the bottom) given an approximate pair of tie-points. sec is scaled and rotated as necessary before the join.

func (*Image) NIFTISave

func (th *Image) NIFTISave(filename string) (err error)

NIFTISave write a VIPS image to a file as NIFTI.

func (*Image) PNGSave

func (th *Image) PNGSave(filename string) (err error)

PNGSave write a VIPS image to a file as PNG.

func (*Image) PNGSaveBuffer

func (th *Image) PNGSaveBuffer() (buf []byte, size int, err error)

PNGSaveBuffer as PNGSave, but save to a memory buffer.

func (*Image) PPMSave

func (th *Image) PPMSave(filename string) (err error)

PPMSave write a VIPS image to a file as PPM.

func (*Image) Phasecor

func (th *Image) Phasecor(in *Image) (err error)

Phasecor convert the two input images to Fourier space, calculate phase-correlation, back to real space.

func (*Image) RADSave

func (th *Image) RADSave(filename string) (err error)

RADSave write a VIPS image to a file as RAD.

func (*Image) RADSaveBuffer

func (th *Image) RADSaveBuffer() (buf []byte, size int, err error)

RADSaveBuffer as RADSave, but save to a memory buffer.

func (*Image) RawSave

func (th *Image) RawSave(filename string) (err error)

RawSave write a VIPS image to a file as Raw.

func (*Image) ReMosaic

func (th *Image) ReMosaic(oldStr, newStr string) (err error)

ReMosaic takes apart the mosaiced image in and rebuilds it, substituting images. todo failed: class "remosaic" not found

func (*Image) Replicate

func (th *Image) Replicate(across, down int) (err error)

Replicate repeats an image many times. across: repeat input this many times across down: repeat input this many times down

func (*Image) Resize

func (th *Image) Resize(scale float64) (err error)

Resize image upsizing (scale > 1)

func (*Image) Rotate

func (th *Image) Rotate(angle float64) (err error)

Rotate image

func (*Image) Save2file

func (th *Image) Save2file(filename string) (err error)

Save2file Write *Image to filename in VIPS format.

func (*Image) Scale

func (th *Image) Scale() (err error)

Scale search the image for the maximum and minimum value, then return the image as unsigned 8-bit, scaled so that the maximum value is 255 and the minimum is zero.

func (*Image) SmartCrop

func (th *Image) SmartCrop(width, height int) (err error)

SmartCrop crop an image down to a specified width and height by removing boring parts.

func (*Image) Spectrum

func (th *Image) Spectrum() (err error)

Spectrum make a displayable (ie. 8-bit unsigned int) power spectrum.

func (*Image) SubSample

func (th *Image) SubSample(xFac, yFac int) (err error)

SubSample an image by an integer fraction. This is fast, nearest-neighbour shrink.

func (*Image) TIFFSave

func (th *Image) TIFFSave(filename string) (err error)

TIFFSave write a VIPS image to a file as TIFF.

func (*Image) TIFFSaveBuffer

func (th *Image) TIFFSaveBuffer() (buf []byte, size int, err error)

TIFFSaveBuffer as TIFFSave, but save to a memory buffer.

func (*Image) ThumbnailImage

func (th *Image) ThumbnailImage(width int) (err error)

ThumbnailImage Make a thumbnail from *Image

func (*Image) WEBPSave

func (th *Image) WEBPSave(filename string) (err error)

WEBPSave write a VIPS image to a file as WEBP.

func (*Image) WEBPSaveBuffer

func (th *Image) WEBPSaveBuffer() (buf []byte, size int, err error)

WEBPSaveBuffer as WEBPSave, but save to a memory buffer.

func (*Image) WEBPSaveMime

func (th *Image) WEBPSaveMime() (err error)

WEBPSaveMime As WEBPSave, but save as a mime webp on stdout.

func (*Image) Width

func (th *Image) Width() int

Width return image width

func (*Image) Wrap

func (th *Image) Wrap() (err error)

Wrap slice an image up and move the segments about so that the pixel that was at 0, 0 is now at x , y . If x and y are not set, they default to the centre of the image.

func (*Image) Zoom

func (th *Image) Zoom(xFac, yFac int) (err error)

Zoom an image by repeating pixels. This is fast nearest-neighbour zoom.

Jump to

Keyboard shortcuts

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