fotomat: Index | Files

package vips

import ""


Package Files

arithmetic.go colour.go conversion.go convolution.go foreign.go header.go image.go init.go resample.go util.go


const (
    ExifOrientation = "exif-ifd0-Orientation"
    MetaIccName     = "icc-profile-data"

Potential values for ImageGetAsString.


var (
    // ErrImageOp means VIPS returned an error but we couldn't get error text.
    ErrImageOp = errors.New("Image operation error")
var (
    // ResizeOffset is how much padding is necessary to add to
    // (*Image).Resize() scaling calculations, in pixels.  Set to 0 as
    // of VIPS 8.4, and 0.5 for earlier versons.
    ResizeOffset = 0.0

func Initialize Uses

func Initialize()

Initialize starts up the world of VIPS. You should call this on program startup before using any other VIPS operations.

func LeakSet Uses

func LeakSet(enable bool)

LeakSet turns leak checking on or off. You should call this very early in your program.

func Shutdown Uses

func Shutdown()

Shutdown drops caches and closes plugins, and runs a leak check if requested. May be called many times.

func ThreadShutdown Uses

func ThreadShutdown()

ThreadShutdown frees any thread-private data and flushes any profiling information. This function needs to be called when a thread that has been using vips exits or there will be memory leaks. It may be called many times, and you can continue using vips after calling it. Calling it too often will reduce performance.

type Angle Uses

type Angle int

Angle specifies fixed rotation angles

const (
    Angle0   Angle = C.VIPS_ANGLE_D0   // does not rotate
    Angle90  Angle = C.VIPS_ANGLE_D90  // 90 degrees counter-clockwise
    Angle180 Angle = C.VIPS_ANGLE_D180 // 180 degrees
    Angle270 Angle = C.VIPS_ANGLE_D270 // 90 degrees clockwise

Various Angle values understood by VIPS.

type BandFormat Uses

type BandFormat int

BandFormat is the format used for each band element. Each corresponds to a native C type for the current machine.

const (
    BandFormatNotSet    BandFormat = C.VIPS_FORMAT_NOTSET
    BandFormatUchar     BandFormat = C.VIPS_FORMAT_UCHAR
    BandFormatChar      BandFormat = C.VIPS_FORMAT_CHAR
    BandFormatUshort    BandFormat = C.VIPS_FORMAT_USHORT
    BandFormatShort     BandFormat = C.VIPS_FORMAT_SHORT
    BandFormatUint      BandFormat = C.VIPS_FORMAT_UINT
    BandFormatInt       BandFormat = C.VIPS_FORMAT_INT
    BandFormatFloat     BandFormat = C.VIPS_FORMAT_FLOAT
    BandFormatComplex   BandFormat = C.VIPS_FORMAT_COMPLEX
    BandFormatDouble    BandFormat = C.VIPS_FORMAT_DOUBLE
    BandFormatDpComplex BandFormat = C.VIPS_FORMAT_DPCOMPLEX

Potential values that GetBandFormat will return.

type Direction Uses

type Direction int

Direction specifies which direction to flip an image

const (
    DirectionHorizontal Direction = C.VIPS_DIRECTION_HORIZONTAL // left-right
    DirectionVertical   Direction = C.VIPS_DIRECTION_VERTICAL   // top-bottom

Various Direction values undertood by VIPS.

type Extend Uses

type Extend int

Extend specifies how to extend edges of an image

const (
    ExtendBlack      Extend = C.VIPS_EXTEND_BLACK      // extends with black (all 0) pixels
    ExtendCopy       Extend = C.VIPS_EXTEND_COPY       // copies the image edges
    ExtendRepeat     Extend = C.VIPS_EXTEND_REPEAT     // repeats the whole image
    ExtendMirror     Extend = C.VIPS_EXTEND_MIRROR     // mirrors the whole image
    ExtendWhite      Extend = C.VIPS_EXTEND_WHITE      // extends with white (all bits set) pixels
    ExtendBackground Extend = C.VIPS_EXTEND_BACKGROUND // extends with colour from the background property

Various Extend values understand by VIPS.

type Image Uses

type Image struct {
    // contains filtered or unexported fields

Image can represent an image on disc, a memory buffer, or a partially evaluated image in memory, represented as its source data and chain of operations to be performed on that image later.

func Gifload Uses

func Gifload(filename string) (*Image, error)

Gifload reads a GIF file into an Image.

func GifloadBuffer Uses

func GifloadBuffer(buf []byte) (*Image, error)

GifloadBuffer reads a GIF byte slice into an Image.

func Jpegload Uses

func Jpegload(filename string) (*Image, error)

Jpegload reads and returns a JPEG file as an Image.

func JpegloadBuffer Uses

func JpegloadBuffer(buf []byte) (*Image, error)

JpegloadBuffer reads and returns a JPEG byte slice as an Image.

func JpegloadBufferShrink Uses

func JpegloadBufferShrink(buf []byte, shrink int) (*Image, error)

JpegloadBufferShrink reads and returns a JPEG byte slice as an Image, shrinking by an integer factor of 1, 2, 4, or 8 during load. Shrinking during read is very much faster than decompressing the whole image and then shrinking later.

func JpegloadShrink Uses

func JpegloadShrink(filename string, shrink int) (*Image, error)

JpegloadShrink reads and returns a JPEG file as an Image, shrinking by an integer factor of 1, 2, 4, or 8 during load. Shrinking during read is much faster than decompressing the whole image and then resizing later.

func Pngload Uses

func Pngload(filename string) (*Image, error)

Pngload reads a PNG file into an Image.

func PngloadBuffer Uses

func PngloadBuffer(buf []byte) (*Image, error)

PngloadBuffer reads a PNG byte slice into an Image.

func Webpload Uses

func Webpload(filename string) (*Image, error)

Webpload read a WebP file into an Image.

func WebploadBuffer Uses

func WebploadBuffer(buf []byte) (*Image, error)

WebploadBuffer read a WebP byte slice into an Image.

func WebploadBufferShrink Uses

func WebploadBufferShrink(buf []byte, shrink int) (*Image, error)

WebploadBufferShrink read a WebP byte slice into an Image, shrinking by an integer factor of 1 to 1024 during load. Shrinking during read is much faster than decompressing the whole image and then resizing later.

func WebploadShrink Uses

func WebploadShrink(filename string, shrink int) (*Image, error)

WebploadShrink read a WebP file into an Image, shrinking by an integer factor of 1 to 1024 during load. Shrinking during read is much faster than decompressing the whole image and then resizing later.

func (*Image) Affine Uses

func (in *Image) Affine(a, b, c, d float64, interpolate *Interpolate) error

Affine performs this affine transform on the input image using the supplied interpolate:

X = a * (x + idx ) + b * (y + idy ) + odx
Y = c * (x + idx ) + d * (y + idy ) + doy

x and y are the coordinates in input image. X and Y are the coordinates in output image. (0,0) is the upper left corner.

func (*Image) Cast Uses

func (in *Image) Cast(format BandFormat) error

Cast converts in to BandFormat. Floats are truncated (not rounded). Out of range values are clipped.

func (*Image) Close Uses

func (in *Image) Close()

Close frees the memory associated with an Image.

func (*Image) Colourspace Uses

func (in *Image) Colourspace(space Interpretation) error

Colourspace moves an image to a target colourspace using the best sequence of colour transform operations.

func (*Image) Copy Uses

func (in *Image) Copy() (*Image, error)

Copy an image by copying pointers, so this operation is instant, even for very large images.

func (*Image) Embed Uses

func (in *Image) Embed(left, top, width, height int, extend Extend) error

Embed in within an image of size width by height at position x, y. Extend controls what appears in the new pixels.

func (*Image) ExtractArea Uses

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

ExtractArea extract an area from an image. The area must fit within in.

func (*Image) ExtractBand Uses

func (in *Image) ExtractBand(band, n int) error

ExtractBand extracts band (channel) number n from in. Extracting out of range is an error.

func (*Image) Flatten Uses

func (in *Image) Flatten() error

Flatten takes the last band of in as an alpha and use it to blend the remaining channels with black, then remove the alpha channel.

func (*Image) Flip Uses

func (in *Image) Flip(direction Direction) error

Flip an image left-right or up-down.

func (*Image) Gaussblur Uses

func (in *Image) Gaussblur(sigma float64) error

Gaussblur creates a circularly symmetric Gaussian mask of radius sigma and performs a separable (two-pass) convolution of in with it.

func (*Image) HasAlpha Uses

func (in *Image) HasAlpha() bool

HasAlpha returns true if the image's last band is an alpha channel.

func (*Image) IccImport Uses

func (in *Image) IccImport() error

IccImport moves an image from device space to D65 LAB using the image's embedded ICC profile.

func (*Image) IccTransform Uses

func (in *Image) IccTransform(outputProfileFilename string, inputProfileFilename string, intent Intent) error

IccTransform transform an image with a pair of ICC profiles. The input image is moved to profile-connection space with the input profile and then to the output space with the output profile and intent.

func (*Image) ImageFieldExists Uses

func (in *Image) ImageFieldExists(field string) bool

ImageFieldExists checks whether a metadata field exists.

func (*Image) ImageGetAsString Uses

func (in *Image) ImageGetAsString(field string) (string, bool)

ImageGetAsString returns the contents of Image's metadata field as a string along with a bool which will be true on success.

func (*Image) ImageGetBandFormat Uses

func (in *Image) ImageGetBandFormat() BandFormat

ImageGetBandFormat returns the BandFormat of each band element.

func (*Image) ImageGetBands Uses

func (in *Image) ImageGetBands() int

ImageGetBands returns the number of bands (channels) in the image.

func (*Image) ImageGuessInterpretation Uses

func (in *Image) ImageGuessInterpretation() Interpretation

ImageGuessInterpretation returns the Interpretation for an image, guessing a sane value if the set value looks crazy.

func (*Image) ImageRemove Uses

func (in *Image) ImageRemove(field string) bool

ImageRemove finds and removes an item of metadata. Return false if no metadata of that name was found.

func (*Image) JpegsaveBuffer Uses

func (in *Image) JpegsaveBuffer(strip bool, q int, optimizeCoding, interlace bool) ([]byte, error)

JpegsaveBuffer write a VIPS image to a byte slice as JPEG. Strip removes all metadata from an image. OptimizeCoding computes and uses optimal Huffman coding tables and attaches them. Interlace write an interlaced (progressive) JPEG.

func (*Image) MaxAlpha Uses

func (in *Image) MaxAlpha() float64

MaxAlpha returns the maximum value for an alpha channel in current BandFormat of image.

func (*Image) MildSharpen Uses

func (in *Image) MildSharpen() error

MildSharpen performs a fast, mild sharpen of an Image.

func (*Image) Min Uses

func (in *Image) Min() (float64, error)

Min finds the single smallest value in all bands of the input image.

func (*Image) PhotoMetric Uses

func (in *Image) PhotoMetric(threshold float64) (int, error)

PhotoMetric takes a histogram of a Sobel edge detect of our image. Returns the highest number of histogram values in a row that are more than the maximum value * threshhold. With a threshold of 0.01, more than 16 indicates a photo.

func (*Image) PngsaveBuffer Uses

func (in *Image) PngsaveBuffer(strip bool, compression int, interlace bool) ([]byte, error)

PngsaveBuffer write a VIPS image to a byte slice as PNG. Strip removes all metadata from an image. Compression supplies the gzip level of effort to use (1 - 9). Interlace writes the image with ADAM7 interlacing, which is up to 7x slower.

func (*Image) Premultiply Uses

func (in *Image) Premultiply() error

Premultiply any alpha channel. The final band is taken to be the alpha.

func (*Image) Resize Uses

func (in *Image) Resize(xscale, yscale float64) error

Resize an image using the bicubic interpolator. When upsizing (scale > 1), the image is simply resized with Affine(). When downsizing, the image is block-shrunk with Shrink() to roughly half the interpolator window size above the target size, then blurred with an anti-alias filter, then resampled with Affine(), then sharpened.

func (*Image) Rot Uses

func (in *Image) Rot(angle Angle) error

Rot rotates an image by a fixed angle.

func (*Image) Sharpen Uses

func (in *Image) Sharpen(radius int, x1, y2, y3, m1, m2 float64) error

Sharpen performs a gaussian blur of radius and subtracts from in to generate a high-frequency signal. This signal is passed through a lookup table generated from the parameters (x1: flat/jaggy threshold, y2: maximum amount of brightening, y3: maximum amount of darkening, m1: slope for flat areas, m2: slope for jaggy areas) and added back to in.

func (*Image) Shrink Uses

func (in *Image) Shrink(xshrink, yshrink float64) error

Shrink in by a pair of factors with a simple box filter. You will get aliasing for non-integer shrinks. In this case, shrink with this function to the nearest integer size above the target shrink, then downsample to the exact size with Affine().

func (*Image) Sobel Uses

func (in *Image) Sobel() error

Sobel is an edge detection filter that converts in to black and white and subtracts pixels from their neighbors. The values that remain are higher when the brightness of a given pixel differs greatly from its neighbors.

func (*Image) Unpremultiply Uses

func (in *Image) Unpremultiply() error

Unpremultiply any alpha channel. The final band is taken to be the alpha.

func (*Image) WebpsaveBuffer Uses

func (in *Image) WebpsaveBuffer(q int, lossless bool) ([]byte, error)

WebpsaveBuffer writes an Image to a WebP byte slice. Q specifies the compression factor for RGB channels between 0 and 100. Lossless encodes the image without any loss, at a large file size.

func (*Image) Write Uses

func (in *Image) Write() error

Write applies all queued operations to the source image copies the result to a new memory buffer.

func (*Image) Xsize Uses

func (in *Image) Xsize() int

Xsize returns the width of the image in pixels.

func (*Image) Ysize Uses

func (in *Image) Ysize() int

Ysize returns the height of the image in pixels.

type Intent Uses

type Intent int

Intent is the color management system rendering intent.

const (
    IntentPerceptual Intent = C.VIPS_INTENT_PERCEPTUAL // best for business graphics
    IntentRelative   Intent = C.VIPS_INTENT_RELATIVE   // best for accurate communication with other imaging libraries
    IntentSaturation Intent = C.VIPS_INTENT_SATURATION // best for business graphics
    IntentAbsolute   Intent = C.VIPS_INTENT_ABSOLUTE   // best for scientific work

Various Intent values understood by VIPS.

type Interpolate Uses

type Interpolate struct {
    // contains filtered or unexported fields

Interpolate is an instance of an interpolator used by Affine.

func NewInterpolate Uses

func NewInterpolate(name string) *Interpolate

NewInterpolate creates an Interpolate instance from a nickname (nearest, bilinear, bicubic, lbb, nohalo, or vsqbs) and makes one. Must be closed when you're done with it.

func (Interpolate) Close Uses

func (i Interpolate) Close()

Close frees resources from an Interpolate.

type Interpretation Uses

type Interpretation int

Interpretation suggests how the values in an image should be interpreted. For example, a three-band float image of type InterpretationLAB should have its pixels interpreted as coordinates in CIE Lab space.

const (
    InterpretationMultiband Interpretation = C.VIPS_INTERPRETATION_MULTIBAND
    InterpretationBW        Interpretation = C.VIPS_INTERPRETATION_B_W
    InterpretationHistogram Interpretation = C.VIPS_INTERPRETATION_HISTOGRAM
    InterpretationXYZ       Interpretation = C.VIPS_INTERPRETATION_XYZ
    InterpretationLAB       Interpretation = C.VIPS_INTERPRETATION_LAB
    InterpretationCMYK      Interpretation = C.VIPS_INTERPRETATION_CMYK
    InterpretationLABQ      Interpretation = C.VIPS_INTERPRETATION_LABQ
    InterpretationRGB       Interpretation = C.VIPS_INTERPRETATION_RGB
    InterpretationCMC       Interpretation = C.VIPS_INTERPRETATION_CMC
    InterpretationLCH       Interpretation = C.VIPS_INTERPRETATION_LCH
    InterpretationLABS      Interpretation = C.VIPS_INTERPRETATION_LABS
    InterpretationSRGB      Interpretation = C.VIPS_INTERPRETATION_sRGB
    InterpretationYXY       Interpretation = C.VIPS_INTERPRETATION_YXY
    InterpretationFourier   Interpretation = C.VIPS_INTERPRETATION_FOURIER
    InterpretationRGB16     Interpretation = C.VIPS_INTERPRETATION_RGB16
    InterpretationGrey16    Interpretation = C.VIPS_INTERPRETATION_GREY16
    InterpretationMatrix    Interpretation = C.VIPS_INTERPRETATION_MATRIX
    InterpretationScRGB     Interpretation = C.VIPS_INTERPRETATION_scRGB

Various Interpretation values understood by VIPS.

Package vips imports 5 packages (graph) and is imported by 2 packages. Updated 2016-11-13. Refresh now. Tools for package owners.