Low-level bindings for libvips. For better shooting to the leg.
Implements VipsOperation builder, which allows you to call most of the existing image operations in the library.
- livips 8+ (a higher version is usually better)
- Go 1.11+ (should work on lower versions, but I did not check)
To reduce memory leak and avoid possible SIGSEGV is recommended to disable libvips cache and vector calculations, i.e. use:
imgvips.VipsCacheSetMaxMem(0)
imgvips.VipsCacheSetMax(0)
imgvips.VipsVectorSetEnables(false)
See examples folder.
op, err := imgvips.NewOperation("webpload")
if err != nil {
panic(err)
}
defer op.Free()
out := imgvips.GNullVipsImage()
op.AddInput("filename", imgvips.GString("path/to/image.webp"))
op.AddOutput("out", out)
if err := op.Exec(); err != nil {
panic(err)
}
op, err := imgvips.NewOperation("webpload_buffer")
if err != nil {
panic(err)
}
defer op.Free()
out := imgvips.GNullVipsImage()
op.AddInput("buffer", imgvips.GVipsBlob(data))
op.AddOutput("out", out)
if err := op.Exec(); err != nil {
panic(err)
}
op, err := imgvips.NewOperation("jpegsave")
if err != nil {
panic(err)
}
defer op.Free()
op.AddInput("in", gImage)
op.AddInput("filename", imgvips.GString("image.jpg"))
if err := op.Exec(); err != nil {
panic(err)
}
op, err := imgvips.NewOperation("jpegsave_buffer")
if err != nil {
panic(err)
}
defer op.Free()
gData := imgvips.GNullVipsBlob()
op.AddInput("in", gImage)
op.AddOutput("buffer", gData)
if err := op.Exec(); err != nil {
panic(err)
}