1 Star 0 Fork 0

wkiny / go-vips

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
vip.go 1.30 KB
一键复制 编辑 原始数据 按行查看 历史
gladmo 提交于 2019-10-09 15:27 . Implement most libvips interfaces
package vips
/*
#cgo pkg-config: vips
#include "vips.h"
*/
import "C"
import (
"errors"
"fmt"
"runtime"
"unsafe"
)
// DefaultInit init vips by default
func DefaultInit() {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
if err := Init(); err != nil {
Shutdown()
panic(fmt.Sprintf("unable to start vips! err: %s", err.Error()))
}
}
// Init starts up libvips
func Init() (err error) {
name := C.CString("vipsimage")
defer C.free(unsafe.Pointer(name))
if C.vips_init(name) != 0 {
return Error()
}
return
}
// Shutdown drop caches and close plugins. Run with "--vips-leak" to do a leak check too.
func Shutdown() {
C.vips_shutdown()
}
// LeakSet turn on or off vips leak checking
func LeakSet(leak bool) {
C.vips_leak_set(btoi(leak))
}
// VersionString get the VIPS version as a static string,
// including a build date and time. Do not free.
func VersionString() string {
return C.GoString(C.vips_version_string())
}
// Version get the major, minor or micro library version, with flag values 0, 1 and 2.
func Version(flag int) int {
return int(C.vips_version(C.int(flag)))
}
// 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 Error() error {
return errors.New(C.GoString(C.vips_error_buffer()))
}
1
https://gitee.com/shiqiyue/go-vips.git
git@gitee.com:shiqiyue/go-vips.git
shiqiyue
go-vips
go-vips
v0.0.1

搜索帮助

53164aa7 5694891 3bd8fe86 5694891