vips

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultFont = "sans 10"
View Source
const MajorVersion = int(C.VIPS_MAJOR_VERSION)

noinspection GoUnusedConst

View Source
const MicroVersion = int(C.VIPS_MICRO_VERSION) // A.K.A patch version

noinspection GoUnusedConst

View Source
const MinorVersion = int(C.VIPS_MINOR_VERSION)

noinspection GoUnusedConst

View Source
const Version = string(C.VIPS_VERSION)

noinspection GoUnusedConst

Variables

View Source
var (
	// ErrUnsupportedImageFormat when image type is unsupported
	ErrUnsupportedImageFormat = errors.New("unsupported image format")
)
View Source
var ImageTypes = map[ImageType]string{
	ImageTypeGIF:    "gif",
	ImageTypeJPEG:   "jpeg",
	ImageTypeMagick: "magick",
	ImageTypePDF:    "pdf",
	ImageTypePNG:    "png",
	ImageTypeSVG:    "svg",
	ImageTypeTIFF:   "tiff",
	ImageTypeWEBP:   "webp",
	ImageTypeHEIF:   "heif",
	ImageTypeBMP:    "bmp",
}

Functions

func ClearCache

func ClearCache()

noinspection GoUnusedExportedFunction

func IsTypeSupported

func IsTypeSupported(imageType ImageType) bool

func PrintCache

func PrintCache()

noinspection GoUnusedExportedFunction

func PrintObjectReport

func PrintObjectReport(label string)

PrintObjectReport outputs all of the current internal objects in libvips

func ReadRuntimeStats

func ReadRuntimeStats(stats *RuntimeStats)

func ReadVipsMemStats

func ReadVipsMemStats(stats *MemoryStats)

func Shutdown

func Shutdown()

Shutdown libvips

func ShutdownThread

func ShutdownThread()

ShutdownThread clears the cache for for the given thread

func Startup

func Startup(config *Config)

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

Types

type Align

type Align int

Align represents VIPS_ALIGN

const (
	AlignLow    Align = C.VIPS_ALIGN_LOW
	AlignCenter Align = C.VIPS_ALIGN_CENTRE
	AlignHigh   Align = C.VIPS_ALIGN_HIGH
)

Direction enum

type Angle

type Angle int

Angle represents VIPS_ANGLE type

const (
	Angle0   Angle = C.VIPS_ANGLE_D0
	Angle90  Angle = C.VIPS_ANGLE_D90
	Angle180 Angle = C.VIPS_ANGLE_D180
	Angle270 Angle = C.VIPS_ANGLE_D270
)

Angle enum

func GetRotationAngleFromExif

func GetRotationAngleFromExif(orientation int) (Angle, bool)

type Angle45

type Angle45 int

Angle45 represents VIPS_ANGLE45 type

const (
	Angle45_0   Angle45 = C.VIPS_ANGLE45_D0
	Angle45_45  Angle45 = C.VIPS_ANGLE45_D45
	Angle45_90  Angle45 = C.VIPS_ANGLE45_D90
	Angle45_135 Angle45 = C.VIPS_ANGLE45_D135
	Angle45_180 Angle45 = C.VIPS_ANGLE45_D180
	Angle45_225 Angle45 = C.VIPS_ANGLE45_D225
	Angle45_270 Angle45 = C.VIPS_ANGLE45_D270
	Angle45_315 Angle45 = C.VIPS_ANGLE45_D315
)

Angle45 enum

type BandFormat

type BandFormat int

BandFormat represents VIPS_FORMAT type

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
)

BandFormat enum

type BlendMode

type BlendMode int

type Coding

type Coding int

Coding represents VIPS_CODING type

const (
	CodingError Coding = C.VIPS_CODING_ERROR
	CodingNone  Coding = C.VIPS_CODING_NONE
	CodingLABQ  Coding = C.VIPS_CODING_LABQ
	CodingRAD   Coding = C.VIPS_CODING_RAD
)

Coding enum

type Color

type Color struct {
	R, G, B uint8
}

Color represents an RGB

type Config

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

Config allows fine-tuning of libvips library

type Direction

type Direction int

Direction represents VIPS_DIRECTION type

const (
	DirectionHorizontal Direction = C.VIPS_DIRECTION_HORIZONTAL
	DirectionVertical   Direction = C.VIPS_DIRECTION_VERTICAL
)

Direction enum

type ExportParams

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

ExportParams are options when exporting an image to file or buffer

func NewDefaultExportParams

func NewDefaultExportParams() *ExportParams

func NewDefaultJPEGExportParams

func NewDefaultJPEGExportParams() *ExportParams

func NewDefaultPNGExportParams

func NewDefaultPNGExportParams() *ExportParams

func NewDefaultWEBPExportParams

func NewDefaultWEBPExportParams() *ExportParams

type ExtendStrategy

type ExtendStrategy int

ExtendStrategy represents VIPS_EXTEND type

ExtendStrategy enum

type ImageMetadata

type ImageMetadata struct {
	Format      ImageType
	Width       int
	Height      int
	Colorspace  Interpretation
	Orientation int
}

type ImageRef

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

ImageRef contains a libvips image and manages its lifecycle. You need to close an image when done or it will leak

func NewImageFromBuffer

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

NewImageFromBuffer loads an image buffer and creates a new Image

func NewImageFromFile

func NewImageFromFile(file string) (*ImageRef, error)

NewImageFromFile loads an image from file and creates a new ImageRef

func NewImageFromReader

func NewImageFromReader(r io.Reader) (*ImageRef, error)

NewImageFromReader loads an ImageRef from the given reader

func (*ImageRef) AddAlpha

func (r *ImageRef) AddAlpha() error

func (*ImageRef) AutoRotate

func (r *ImageRef) AutoRotate() error

func (*ImageRef) BandFormat

func (r *ImageRef) BandFormat() BandFormat

BandFormat returns the current band format

func (*ImageRef) BandJoin

func (r *ImageRef) BandJoin(images ...*ImageRef) error

func (*ImageRef) Bands

func (r *ImageRef) Bands() int

Bands returns the number of bands for this image

func (*ImageRef) Close

func (r *ImageRef) Close()

Close closes an image and frees internal memory associated with it

func (*ImageRef) Coding

func (r *ImageRef) Coding() Coding

Coding returns the image coding

func (*ImageRef) ColorSpace

func (r *ImageRef) ColorSpace() Interpretation

Alias to Interpretation()

func (*ImageRef) Composite

func (r *ImageRef) Composite(overlay *ImageRef, mode BlendMode, x, y int) error

func (*ImageRef) Copy

func (r *ImageRef) Copy() (*ImageRef, error)

create a new ref deprecated

func (*ImageRef) Embed

func (r *ImageRef) Embed(left, top, width, height int, extend ExtendStrategy) error

Embed executes the 'embed' operation

func (*ImageRef) Export

func (r *ImageRef) Export(params *ExportParams) ([]byte, *ImageMetadata, error)

Export exports the image

func (*ImageRef) ExtractArea

func (r *ImageRef) ExtractArea(left, top, width, height int) error

ExtractArea executes the 'extract_area' operation

func (*ImageRef) ExtractBand

func (r *ImageRef) ExtractBand(band int, num int) error

ExtractBand executes the 'extract_band' operation

func (*ImageRef) Flatten

func (r *ImageRef) Flatten(backgroundColor *Color) error

Flatten executes the 'flatten' operation

func (*ImageRef) Flip

func (r *ImageRef) Flip(direction Direction) error

Flip executes the 'flip' operation

func (*ImageRef) Format

func (r *ImageRef) Format() ImageType

Format returns the initial format of the vips image when loaded

func (*ImageRef) GaussianBlur

func (r *ImageRef) GaussianBlur(sigma float64) error

Gaussblur executes the 'gaussblur' operation

func (*ImageRef) GetOrientation

func (r *ImageRef) GetOrientation() int

Return the orientation number as appears in the EXIF, if present

func (*ImageRef) HasAlpha

func (r *ImageRef) HasAlpha() bool

HasAlpha returns if the image has an alpha layer.

func (*ImageRef) HasICCProfile

func (r *ImageRef) HasICCProfile() bool

alias to HasProfile()

func (*ImageRef) HasIPTC

func (r *ImageRef) HasIPTC() bool

func (*ImageRef) HasProfile

func (r *ImageRef) HasProfile() bool

HasProfile returns if the image has an ICC profile embedded.

func (*ImageRef) Height

func (r *ImageRef) Height() int

Height returns the height of this iamge

func (*ImageRef) Interpretation

func (r *ImageRef) Interpretation() Interpretation

Interpretation returns the current interpretation

func (*ImageRef) Invert

func (r *ImageRef) Invert() error

Invert executes the 'invert' operation

func (*ImageRef) IsColorSpaceSupported

func (r *ImageRef) IsColorSpaceSupported() bool

func (*ImageRef) Label

func (r *ImageRef) Label(labelParams *LabelParams) error

Label executes the 'label' operation

func (*ImageRef) Linear

func (r *ImageRef) Linear(a, b []float64) error

func (*ImageRef) Linear1

func (r *ImageRef) Linear1(a, b float64) error

func (*ImageRef) Metadata

func (r *ImageRef) Metadata() *ImageMetadata

func (*ImageRef) Modulate

func (r *ImageRef) Modulate(brightness, saturation float64, hue int) error

Modulate the colors

func (*ImageRef) ModulateHSV

func (r *ImageRef) ModulateHSV(brightness, saturation float64, hue int) error

Modulate the colors

func (*ImageRef) OffsetX

func (r *ImageRef) OffsetX() int

OffsetX returns the X offset

func (*ImageRef) OffsetY

func (r *ImageRef) OffsetY() int

OffsetY returns the Y offset

func (*ImageRef) OptimizeICCProfile

func (r *ImageRef) OptimizeICCProfile() error

func (*ImageRef) PremultiplyAlpha

func (r *ImageRef) PremultiplyAlpha() error

func (*ImageRef) RemoveICCProfile

func (r *ImageRef) RemoveICCProfile() error

func (*ImageRef) RemoveMetadata

func (r *ImageRef) RemoveMetadata() error

won't remove the ICC profile

func (*ImageRef) RemoveOrientation

func (r *ImageRef) RemoveOrientation() error

func (*ImageRef) ResX

func (r *ImageRef) ResX() float64

ResX returns the X resolution

func (*ImageRef) ResY

func (r *ImageRef) ResY() float64

ResY returns the Y resolution

func (*ImageRef) Resize

func (r *ImageRef) Resize(scale float64, kernel Kernel) error

Resize executes the 'resize' operation

func (*ImageRef) ResizeWithVScale

func (r *ImageRef) ResizeWithVScale(hScale, vScale float64, kernel Kernel) error

func (*ImageRef) Rotate

func (r *ImageRef) Rotate(angle Angle) error

Rotate executes the 'rot' operation

func (*ImageRef) SetOrientation

func (r *ImageRef) SetOrientation(orientation int) error

func (*ImageRef) Sharpen

func (r *ImageRef) Sharpen(sigma float64, x1 float64, m2 float64, mode SharpenMode) error

Sharpen executes the 'sharpen' operation

func (*ImageRef) ToBytes

func (r *ImageRef) ToBytes() ([]byte, error)

ToBytes writes the image to memory in VIPs format and returns the raw bytes, useful for storage.

func (*ImageRef) ToColorSpace

func (r *ImageRef) ToColorSpace(interpretation Interpretation) error

func (*ImageRef) UnpremultiplyAlpha

func (r *ImageRef) UnpremultiplyAlpha() error

func (*ImageRef) Width

func (r *ImageRef) Width() int

Width returns the width of this image

func (*ImageRef) Zoom

func (r *ImageRef) Zoom(xFactor int, yFactor int) error

Zoom executes the 'zoom' operation

type ImageType

type ImageType int

ImageType represents an image type

const (
	ImageTypeUnknown ImageType = C.UNKNOWN
	ImageTypeGIF     ImageType = C.GIF
	ImageTypeJPEG    ImageType = C.JPEG
	ImageTypeMagick  ImageType = C.MAGICK
	ImageTypePDF     ImageType = C.PDF
	ImageTypePNG     ImageType = C.PNG
	ImageTypeSVG     ImageType = C.SVG
	ImageTypeTIFF    ImageType = C.TIFF
	ImageTypeWEBP    ImageType = C.WEBP
	ImageTypeHEIF    ImageType = C.HEIF
	ImageTypeBMP     ImageType = C.BMP
)

ImageType enum

func DetermineImageType

func DetermineImageType(buf []byte) ImageType

DetermineImageType attempts to determine the image type of the given buffer

func (ImageType) FileExt

func (i ImageType) FileExt() string

FileExt returns the canonical extension for the ImageType

type Interpretation

type Interpretation int

Interpretation represents VIPS_INTERPRETATION type

type Kernel

type Kernel int

Kernel represents VipsKernel type

const (
	KernelAuto     Kernel = -1
	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
	KernelMitchell Kernel = C.VIPS_KERNEL_MITCHELL
)

Kernel enum

type LabelParams

type LabelParams struct {
	Text      string
	Font      string
	Width     Scalar
	Height    Scalar
	OffsetX   Scalar
	OffsetY   Scalar
	Opacity   float32
	Color     Color
	Alignment Align
}

LabelParams represents a text-based label

type MemoryStats

type MemoryStats struct {
	Mem     int64
	MemHigh int64
	Files   int64
	Allocs  int64
}

type PreMultiplicationState

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

type RuntimeStats

type RuntimeStats struct {
	OperationCounts map[string]int64
}

type Scalar

type Scalar struct {
	Value    float64
	Relative bool
}

func ValueOf

func ValueOf(value float64) Scalar

func (*Scalar) Get

func (s *Scalar) Get(base int) float64

func (*Scalar) GetRounded

func (s *Scalar) GetRounded(base int) int

func (*Scalar) IsZero

func (s *Scalar) IsZero() bool

func (*Scalar) Set

func (s *Scalar) Set(value float64)

func (*Scalar) SetInt

func (s *Scalar) SetInt(value int)

func (*Scalar) SetScale

func (s *Scalar) SetScale(f float64)

type SharpenMode

type SharpenMode int
const (
	SharpenModeLuminescence SharpenMode = C.VIPS_SHARPEN_MODE_LUMINESCENCE
	SharpenModeRGB          SharpenMode = C.VIPS_SHARPEN_MODE_RGB
)

Jump to

Keyboard shortcuts

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