vips

package
v0.0.2-0...-da61ce4 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedImageFormat when image type is unsupported
	ErrUnsupportedImageFormat = errors.New("Unsupported image format")
)

Functions

func ExtractImageArea

func ExtractImageArea(imageRef *ImageRef, left, top, width, height int) error

ExtractImageArea crops image to specified size

func GravityImage

func GravityImage(imageRef *ImageRef, direction CompassDirection, width, height int, extend Extend, red, green, blue float64) error

GravityImage changes canvas size with specified direction and canvas fill logic

func HasAlphaChannel

func HasAlphaChannel(imageRef *ImageRef) bool

HasAlphaChannel checks is image have alpha channel or not

func ResizeImage

func ResizeImage(imageRef *ImageRef, scale, vscale float64, kernel Kernel) error

ResizeImage resizes input image with one of the specified interpolation algorithms

func SaveBuffer

func SaveBuffer(imageRef *ImageRef, params *ExportParams) ([]byte, error)

SaveBuffer saves vips image to bytes

func Startup

func Startup(config *StartupConfig)

Startup sets up the vips support and ensures the versions are correct. Pass in nil for default configuration.

Types

type CompassDirection

type CompassDirection int

CompassDirection represents VipsCompassDirection type

CompassDirection enum

type ExportParams

type ExportParams struct {
	Format        ImageType
	Quality       int
	Compression   int
	Interlaced    bool
	Lossless      bool
	StripMetadata bool
}

ExportParams are options when exporting an image to file or buffer

type Extend

type Extend int

Extend represents VipsExtend type

const (
	ExtendBlack      Extend = C.VIPS_EXTEND_BLACK      // Black 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      // White pixels
	ExtendBackground Extend = C.VIPS_EXTEND_BACKGROUND // Selects color from background property
	ExtendLast       Extend = C.VIPS_EXTEND_LAST       // Extends with last pixel
)

Extend enum

type ImageRef

type ImageRef struct {
	Image  *C.VipsImage
	Format ImageType

	// NOTE(d): We keep a reference to this so that the input buffer is
	// never garbage collected during processing. Some image loaders use random
	// access transcoding and therefore need the original buffer to be in memory.
	Buf []byte
}

ImageRef contains a libvips image and manages its lifecycle. You should close an image when done or it will leak until the next GC

func InitImage

func InitImage(buf []byte) (*ImageRef, error)

InitImage opens image in vips

func (*ImageRef) Close

func (ref *ImageRef) Close()

Close closes an image and frees internal memory associated with it

type ImageType

type ImageType int

ImageType represents an image type

const (
	ImageTypeUnknown ImageType = C.UNKNOWN
	ImageTypeJPEG    ImageType = C.JPEG
	ImageTypePNG     ImageType = C.PNG
	ImageTypeTIFF    ImageType = C.TIFF
	ImageTypeWEBP    ImageType = C.WEBP
)

ImageType enum

type Kernel

type Kernel int

Kernel represents VipsKernel type

const (
	KernelNearest  Kernel = C.VIPS_KERNEL_NEAREST
	KernelLinear   Kernel = C.VIPS_KERNEL_LINEAR
	KernelCubic    Kernel = C.VIPS_KERNEL_CUBIC
	KernelLanczos2 Kernel = C.VIPS_KERNEL_LANCZOS2
	KernelLanczos3 Kernel = C.VIPS_KERNEL_LANCZOS3
)

Kernel enum

type StartupConfig

type StartupConfig struct {
	ConcurrencyLevel int
	MaxCacheFiles    int
	MaxCacheMem      int
	MaxCacheSize     int
	ReportLeaks      bool
	CacheTrace       bool
}

StartupConfig allows fine-tuning of libvips library

Jump to

Keyboard shortcuts

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