Ejemplo n.º 1
0
func Shutdown() {
	if !initialized {
		return
	}

	C.vips_shutdown()

	initialized = false
}
Ejemplo n.º 2
0
Archivo: vips.go Proyecto: godeep/bimg
// Thread-safe function to shutdown libvips.
// You can call this to drop caches as well.
// If libvips was already initialized, the function is no-op
func Shutdown() {
	m.Lock()
	defer m.Unlock()

	if initialized {
		C.vips_shutdown()
		initialized = false
	}
}
Ejemplo n.º 3
0
func init() {
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()
	err := C.vips_initialize()
	if err != 0 {
		C.vips_shutdown()
		panic("unable to start vips!")
	}
	C.vips_concurrency_set(1)
	C.vips_cache_set_max_mem(100 * 1048576) // 100Mb
	C.vips_cache_set_max(500)
}
Ejemplo n.º 4
0
// Initialize starts up the world of VIPS. You should call this on program
// startup before using any other VIPS operations.
func Initialize() {
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	_ = os.Setenv("VIPS_WARNING", "disable")

	if err := C.cgo_vips_init(); err != 0 {
		C.vips_shutdown()
		panic("vips_initialize error")
	}

	C.vips_concurrency_set(1)
	C.vips_cache_set_max_mem(0)
	C.vips_cache_set_max(0)

	// Vips 8.3 sometimes produces 1px smaller images than desired without rounding help.
	if C.VIPS_MAJOR_VERSION == 8 && C.VIPS_MINOR_VERSION < 4 {
		ResizeOffset = 0.5
	}
}
Ejemplo n.º 5
0
// Shutdown drops caches and closes plugins, and runs a leak check if
// requested.  May be called many times.
func Shutdown() {
	C.vips_shutdown()
}