MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / GetIntSlice

Method GetIntSlice

vips/vips.go:472–492  ·  view source on GitHub ↗
(name string)

Source from the content-addressed store, hash-verified

470}
471
472func (img *Image) GetIntSlice(name string) ([]int, error) {
473 var ptr unsafe.Pointer
474 size := C.int(0)
475
476 if C.vips_image_get_array_int_go(img.VipsImage, cachedCString(name), (**C.int)(unsafe.Pointer(&ptr)), &size) != 0 {
477 return nil, Error()
478 }
479
480 if size == 0 {
481 return []int{}, nil
482 }
483
484 cOut := (*[math.MaxInt32]C.int)(ptr)[:int(size):int(size)]
485 out := make([]int, int(size))
486
487 for i, el := range cOut {
488 out[i] = int(el)
489 }
490
491 return out, nil
492}
493
494func (img *Image) GetIntSliceDefault(name string, def []int) ([]int, error) {
495 if C.vips_image_get_typeof(img.VipsImage, cachedCString(name)) == 0 {

Callers 1

GetIntSliceDefaultMethod · 0.95

Calls 2

cachedCStringFunction · 0.85
ErrorFunction · 0.70

Tested by

no test coverage detected