func Shutdown() { if !initialized { return } C.vips_shutdown() initialized = false }
// 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 } }
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) }
// 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 } }
// Shutdown drops caches and closes plugins, and runs a leak check if // requested. May be called many times. func Shutdown() { C.vips_shutdown() }