Functions

add_option_entries (option_group)

area_free_cb (mem, area)

band_format_is8bit (format)

band_format_iscomplex (format)

band_format_isfloat (format)

band_format_isint (format)

band_format_isuint (format)

blob_copy (data)

block_untrusted_set (state)

cache_drop_all ()

cache_get_max ()

cache_get_max_files ()

cache_get_max_mem ()

cache_get_size ()

cache_operation_build (operation)

cache_print ()

cache_set_dump (dump)

cache_set_max (max)

cache_set_max_files (max_files)

cache_set_max_mem (max_mem)

cache_set_trace (trace)

call_argv (operation, argc, argv)

call_options (group, operation)

check_8or16 (domain, im)

check_bandno (domain, im, bandno)

check_bands (domain, im, bands)

check_bands_1or3 (domain, im)

check_bands_1orn (domain, im1, im2)

check_bands_1orn_unary (domain, im, n)

check_bands_atleast (domain, im, bands)

check_bands_same (domain, im1, im2)

check_coding (domain, im, coding)

check_coding_known (domain, im)

check_coding_noneorlabq (domain, im)

check_coding_same (domain, im1, im2)

check_complex (domain, im)

check_format (domain, im, fmt)

check_format_same (domain, im1, im2)

check_hist (domain, im)

check_int (domain, im)

check_matrix (domain, im)

check_mono (domain, im)

check_noncomplex (domain, im)

check_oddsquare (domain, im)

check_precision_intfloat (domain, precision)

check_separable (domain, im)

check_size_same (domain, im1, im2)

check_twocomponents (domain, im)

check_u8or16 (domain, im)

check_u8or16orf (domain, im)

check_uint (domain, im)

check_uintorf (domain, im)

check_uncoded (domain, im)

check_vector (domain, n, im)

check_vector_length (domain, n, len)

class_find (basename, nickname)

col_C2Ccmc (C)

col_Ccmc2C (Ccmc)

col_Ch2ab (C, h, a, b)

col_Ch2hcmc (C, h)

col_Chcmc2h (C, hcmc)

col_L2Lcmc (L)

col_Lab2XYZ (L, a, b)

col_Lcmc2L (Lcmc)

col_XYZ2Lab (X, Y, Z)

col_XYZ2scRGB (X, Y, Z)

col_ab2Ch (a, b, C, h)

col_ab2h (a, b)

col_dE00 (L1, a1, b1, L2, a2, b2)

col_make_tables_CMC ()

col_sRGB2scRGB_16 (r, g, b, R, G, B)

col_sRGB2scRGB_16_noclip (r, g, b, R, G, B)

col_sRGB2scRGB_8 (r, g, b, R, G, B)

col_sRGB2scRGB_8_noclip (r, g, b, R, G, B)

col_scRGB2BW_16 (R, G, B, g, og)

col_scRGB2BW_8 (R, G, B, g, og)

col_scRGB2XYZ (R, G, B)

col_scRGB2sRGB_16 (R, G, B, r, g, b, og)

col_scRGB2sRGB_8 (R, G, B, r, g, b, og)

concurrency_get ()

concurrency_set (concurrency)

error_buffer ()

error_buffer_copy ()

error_clear ()

error_freeze ()

error_g ()

error_thaw ()

filename_get_filename (vips_filename)

filename_get_options (vips_filename)

foreign_flags (loader, filename)

format_sizeof (format)

g_error ()

get_argv0 ()

get_disc_threshold ()

get_prgname ()

guess_libdir (argv0, env_name)

guess_prefix (argv0, env_name)

icc_is_compatible_profile (image, data, data_length)

icc_present ()

init (argv0)

interpretation_max_alpha (interpretation)

leak_set (leak)

malloc (object, size)

nickname_find (type)

path_filename7 (path)

path_mode7 (path)

progress_set (progress)

pythagoras (L1, a1, b1, L2, a2, b2)

shutdown ()

strdup (object, str)

thread_shutdown ()

tracked_aligned_alloc (size, align)

tracked_aligned_free (s)

tracked_close (fd)

tracked_free (s)

tracked_get_allocs ()

tracked_get_files ()

tracked_get_mem ()

tracked_get_mem_highwater ()

tracked_malloc (size)

tracked_open (pathname, flags, mode)

type_depth (type)

type_find (basename, nickname)

value_get_area (value)

value_get_array (value)

value_get_array_double (value)

value_get_array_image (value)

value_get_array_int (value)

value_get_blob (value)

value_get_ref_string (value)

value_get_save_string (value)

value_is_null (psoec, value)

value_set_area (value, free_fn, *data)

value_set_array (n, type, sizeof_type)

value_set_array_double (value, array)

value_set_array_image (value, n)

value_set_array_int (value, array)

value_set_array_object (n)

value_set_blob (free_fn, data)

value_set_blob_free (value, data)

value_set_ref_string (str)

value_set_save_string (str)

version (flag)

version_string ()

Details

Vips.add_option_entries(option_group)
Parameters:

option_group (GLib.OptionGroup) – group to add to

Add the standard vips GLib.OptionEntry to a GLib.OptionGroup.

See also: GLib.OptionGroup.new().

Vips.area_free_cb(mem, area)
Parameters:
Return type:

int

Vips.band_format_is8bit(format)
Parameters:

format (Vips.BandFormat) – format to test

Return type:

bool

Return True if format is uchar or schar.

Vips.band_format_iscomplex(format)
Parameters:

format (Vips.BandFormat) – format to test

Return type:

bool

Return True if fmt is one of the complex types.

Vips.band_format_isfloat(format)
Parameters:

format (Vips.BandFormat) – format to test

Return type:

bool

Return True if format is one of the float types.

Vips.band_format_isint(format)
Parameters:

format (Vips.BandFormat) – format to test

Return type:

bool

Return True if format is one of the integer types.

Vips.band_format_isuint(format)
Parameters:

format (Vips.BandFormat) – format to test

Return type:

bool

Return True if format is one of the unsigned integer types.

Vips.blob_copy(data)
Parameters:

data (bytes) – data to store

Returns:

the new Vips.Blob.

Return type:

Vips.Blob

Like Vips.Blob.new(), but take a copy of the data. Useful for bindings which struggle with callbacks.

See also: Vips.Blob.new().

Vips.block_untrusted_set(state)
Parameters:

state (bool) – the block state to set

Set the block state on all untrusted operations.

vips_block_untrusted_set(TRUE);

Will block all untrusted operations from running.

Use vips -l at the command-line to see the class hierarchy and which operations are marked as untrusted.

Set the environment variable VIPS_BLOCK_UNTRUSTED to block all untrusted operations on Vips.init().

Vips.cache_drop_all()

Drop the whole operation cache, handy for leak tracking. Also called automatically on Vips.shutdown().

Vips.cache_get_max()
Returns:

the maximum number of operations we keep in cache

Return type:

int

Get the maximum number of operations we keep in cache.

Vips.cache_get_max_files()
Returns:

the maximum number of tracked files we allow

Return type:

int

Get the maximum number of tracked files we allow before we start dropping cached operations. See Vips.tracked_get_files().

libvips only tracks file descriptors it allocates, it can’t track ones allocated by external libraries. If you use an operation like vips_magickload(), most of the descriptors it uses won’t be included.

See also: Vips.tracked_get_files().

Vips.cache_get_max_mem()
Returns:

the maximum amount of tracked memory we allow

Return type:

int

Get the maximum amount of tracked memory we allow before we start dropping cached operations. See Vips.tracked_get_mem().

See also: Vips.tracked_get_mem().

Vips.cache_get_size()
Returns:

get the current number of operations in cache.

Return type:

int

Get the current number of operations in cache.

Vips.cache_operation_build(operation)
Parameters:

operation (Vips.Operation) – operation to lookup

Returns:

The built operation.

Return type:

Vips.Operation

A binding-friendly version of vips_cache_operation_buildp().

After calling this, operation has the same ref count as when it went in, and the result must be freed with Vips.Object.unref_outputs() and GObject.Object.unref().

Vips.cache_print()

Print the whole operation cache to stdout. Handy for debugging.

Vips.cache_set_dump(dump)
Parameters:

dump (bool) – if True, dump the operation cache on exit

Handy for debugging. Print the operation cache to stdout just before exit.

See also: Vips.cache_set_trace().

Vips.cache_set_max(max)
Parameters:

max (int) – maximum number of operation to cache

Set the maximum number of operations we keep in cache.

Vips.cache_set_max_files(max_files)
Parameters:

max_files (int) – max open files we allow

Set the maximum number of tracked files we allow before we start dropping cached operations. See Vips.tracked_get_files().

See also: Vips.tracked_get_files().

Vips.cache_set_max_mem(max_mem)
Parameters:

max_mem (int) – maximum amount of tracked memory we use

Set the maximum amount of tracked memory we allow before we start dropping cached operations. See Vips.tracked_get_mem().

libvips only tracks memory it allocates, it can’t track memory allocated by external libraries. If you use an operation like vips_magickload(), most of the memory it uses won’t be included.

See also: Vips.tracked_get_mem().

Vips.cache_set_trace(trace)
Parameters:

trace (bool) – if True, trace the operation cache

Handy for debugging. Print operation cache actions to stdout as we run.

You can set the environment variable VIPS_TRACE to turn this option on, or use the command-line flag --vips-cache-trace.

See also: Vips.cache_set_dump().

Vips.call_argv(operation, argc, argv)
Parameters:
Return type:

int

Vips.call_options(group, operation)
Parameters:
Vips.check_8or16(domain, im)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that the image is 8 or 16-bit integer, signed or unsigned. Otherwise set an error message and return non-zero.

See also: vips_error().

Vips.check_bandno(domain, im, bandno)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

  • bandno (int) – band number

Returns:

0 if OK, -1 otherwise.

Return type:

int

bandno should be a valid band number (ie. 0 to im->Bands - 1), or can be -1, meaning all bands. If not, set an error message and return non-zero.

See also: vips_error().

Vips.check_bands(domain, im, bands)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

  • bands (int) – must have this many bands

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that the image has bands bands. Otherwise set an error message and return non-zero.

See also: vips_error().

Vips.check_bands_1or3(domain, im)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that the image has either one or three bands. Otherwise set an error message and return non-zero.

See also: vips_error().

Vips.check_bands_1orn(domain, im1, im2)
Parameters:
  • domain (str) – the originating domain for the error message

  • im1 (Vips.Image) – first image to check

  • im2 (Vips.Image) – second image to check

Returns:

0 on OK, or -1 on error.

Return type:

int

Check that the images have the same number of bands, or that one of the images has just 1 band. If not, set an error message and return non-zero.

See also: vips_error().

Vips.check_bands_1orn_unary(domain, im, n)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

  • n (int) – number of bands, or 1

Returns:

0 on OK, or -1 on error.

Return type:

int

Check that an image has 1 or n bands. Handy for unary operations, cf. Vips.check_bands_1orn(). If not, set an error message and return non-zero.

See also: Vips.check_bands_1orn().

Vips.check_bands_atleast(domain, im, bands)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

  • bands (int) – at least this many bands

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that the image has at least bands bands. Otherwise set an error message and return non-zero.

See also: vips_error().

Vips.check_bands_same(domain, im1, im2)
Parameters:
  • domain (str) – the originating domain for the error message

  • im1 (Vips.Image) – first image to check

  • im2 (Vips.Image) – second image to check

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that the images have the same number of bands. If not, set an error message and return non-zero.

See also: vips_error().

Vips.check_coding(domain, im, coding)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

  • coding (Vips.Coding) – required coding

Returns:

0 on OK, or -1 on error.

Return type:

int

Check that the image has the required coding. If not, set an error message and return non-zero.

See also: vips_error().

Vips.check_coding_known(domain, im)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

Returns:

0 on OK, or -1 on error.

Return type:

int

Check that the image is uncoded, LABQ coded or RAD coded. If not, set an error message and return non-zero.

See also: vips_error().

Vips.check_coding_noneorlabq(domain, im)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

Returns:

0 on OK, or -1 on error.

Return type:

int

Check that the image is uncoded or LABQ coded. If not, set an error message and return non-zero.

See also: vips_error().

Vips.check_coding_same(domain, im1, im2)
Parameters:
  • domain (str) – the originating domain for the error message

  • im1 (Vips.Image) – first image to check

  • im2 (Vips.Image) – second image to check

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that the images have the same coding. If not, set an error message and return non-zero.

See also: vips_error().

Vips.check_complex(domain, im)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that the image is complex. Otherwise set an error message and return non-zero.

See also: vips_error().

Vips.check_format(domain, im, fmt)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

  • fmt (Vips.BandFormat) – format to test for

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that the image has the specified format. Otherwise set an error message and return non-zero.

See also: vips_error().

Vips.check_format_same(domain, im1, im2)
Parameters:
  • domain (str) – the originating domain for the error message

  • im1 (Vips.Image) – first image to check

  • im2 (Vips.Image) – second image to check

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that the images have the same format. If not, set an error message and return non-zero.

See also: vips_error().

Vips.check_hist(domain, im)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

Returns:

0 if OK, -1 otherwise.

Return type:

int

Histogram images must have width or height 1, and must not have more than 65536 elements. Return 0 if the image will pass as a histogram, or -1 and set an error message otherwise.

See also: vips_error().

Vips.check_int(domain, im)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that the image is in one of the integer formats. Otherwise set an error message and return non-zero.

See also: vips_error().

Vips.check_matrix(domain, im)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

Returns:

0 if OK, -1 otherwise.

out:

put image as in-memory doubles here

Return type:

(int, out: Vips.Image)

Matrix images must have width and height less than 100000 and have 1 band.

Return 0 if the image will pass as a matrix, or -1 and set an error message otherwise.

out is set to be im cast to double and stored in memory. Use VIPS_MATRIX() to address values in out.

You must unref out when you are done with it.

See also: VIPS_MATRIX(), vips_object_local()

Vips.check_mono(domain, im)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that the image has exactly one band. Otherwise set an error message and return non-zero.

See also: vips_error().

Vips.check_noncomplex(domain, im)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that the image is not complex. Otherwise set an error message and return non-zero.

See also: vips_error().

Vips.check_oddsquare(domain, im)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that the image is square and that the sides are odd. If not, set an error message and return non-zero.

See also: vips_error().

Vips.check_precision_intfloat(domain, precision)
Parameters:
  • domain (str) – the originating domain for the error message

  • precision (Vips.Precision) – precision to check

Returns:

0 on OK, or -1 on error.

Return type:

int

Check that prec image is either float or int. If not, set an error message and return non-zero.

See also: vips_error().

Vips.check_separable(domain, im)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

Returns:

0 if OK, -1 otherwise.

Return type:

int

Separable matrix images must have width or height 1. Return 0 if the image will pass, or -1 and set an error message otherwise.

See also: vips_error().

Vips.check_size_same(domain, im1, im2)
Parameters:
  • domain (str) – the originating domain for the error message

  • im1 (Vips.Image) – first image to check

  • im2 (Vips.Image) – second image to check

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that the images have the same size. If not, set an error message and return non-zero.

See also: vips_error().

Vips.check_twocomponents(domain, im)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that the image is has two “components”, ie. is a one-band complex or a two-band non-complex. Otherwise set an error message and return non-zero.

See also: vips_error().

Vips.check_u8or16(domain, im)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that the image is 8 or 16-bit unsigned integer. Otherwise set an error message and return non-zero.

See also: vips_error().

Vips.check_u8or16orf(domain, im)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that the image is 8 or 16-bit unsigned integer, or float. Otherwise set an error message and return non-zero.

See also: vips_error().

Vips.check_uint(domain, im)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that the image is in one of the unsigned integer formats. Otherwise set an error message and return non-zero.

See also: vips_error().

Vips.check_uintorf(domain, im)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that the image is unsigned int or float. Otherwise set an error message and return non-zero.

See also: vips_error().

Vips.check_uncoded(domain, im)
Parameters:
  • domain (str) – the originating domain for the error message

  • im (Vips.Image) – image to check

Returns:

0 on OK, or -1 on error.

Return type:

int

Check that the image is not coded. If not, set an error message and return non-zero.

See also: vips_error().

Vips.check_vector(domain, n, im)
Parameters:
  • domain (str) – the originating domain for the error message

  • n (int) – number of elements in vector

  • im (Vips.Image) – image to check against

Returns:

0 if OK, -1 otherwise.

Return type:

int

Operations with a vector constant need a 1-element vector, or a vector with the same number of elements as there are bands in the image, or a 1-band image and a many-element vector.

See also: vips_error().

Vips.check_vector_length(domain, n, len)
Parameters:
  • domain (str) – the originating domain for the error message

  • n (int) – number of elements in vector

  • len (int) – number of elements vector should have

Returns:

0 if OK, -1 otherwise.

Return type:

int

Check that n == len.

See also: vips_error().

Vips.class_find(basename, nickname)
Parameters:
  • basename (str) – name of base class

  • nickname (str) – search for a class with this nickname

Returns:

the found class.

Return type:

Vips.ObjectClass

Search below basename, return the first class whose name or nickname matches.

See also: Vips.type_find()

Vips.col_C2Ccmc(C)
Parameters:

C (float) – Chroma

Returns:

Ccmc.

Return type:

float

Calculate Ccmc from C.

Vips.col_Ccmc2C(Ccmc)
Parameters:

Ccmc (float) – Ccmc

Returns:

Return type:

float

Calculate C from Ccmc using a table. Call Vips.col_make_tables_CMC() at least once before using this function.

Vips.col_Ch2ab(C, h, a, b)
Parameters:
  • C (float) – Chroma

  • h (float) – Hue angle (degrees)

  • a (float) – return CIE a* value

  • b (float) – return CIE b* value

Calculate ab from Ch, h in degrees.

Vips.col_Ch2hcmc(C, h)
Parameters:
  • C (float) – Chroma

  • h (float) – Hue (degrees)

Returns:

hcmc.

Return type:

float

Calculate hcmc from C and h.

Vips.col_Chcmc2h(C, hcmc)
Parameters:
  • C (float) – Chroma

  • hcmc (float) – Hue cmc (degrees)

Returns:

Return type:

float

Calculate h from C and hcmc, using a table. Call Vips.col_make_tables_CMC() at least once before using this function.

Vips.col_L2Lcmc(L)
Parameters:

L (float) – CIE L*

Returns:

Lcmc

Return type:

float

Calculate Lcmc from L.

Vips.col_Lab2XYZ(L, a, b)
Parameters:
  • L (float) – Input CIE Lab value

  • a (float) – Input CIE Lab value

  • b (float) – Input CIE Lab value

Returns:

X:

Return CIE XYZ colour

Y:

Return CIE XYZ colour

Z:

Return CIE XYZ colour

Return type:

(X: float, Y: float, Z: float)

Calculate XYZ from Lab, D65.

See also: vips_Lab2XYZ().

Vips.col_Lcmc2L(Lcmc)
Parameters:

Lcmc (float) – L cmc

Returns:

L*

Return type:

float

Calculate L from Lcmc using a table. Call Vips.col_make_tables_CMC() at least once before using this function.

Vips.col_XYZ2Lab(X, Y, Z)
Parameters:
  • X (float) – Input CIE XYZ colour

  • Y (float) – Input CIE XYZ colour

  • Z (float) – Input CIE XYZ colour

Returns:

L:

Return CIE Lab value

a:

Return CIE Lab value

b:

Return CIE Lab value

Return type:

(L: float, a: float, b: float)

Calculate XYZ from Lab, D65.

See also: vips_XYZ2Lab().

Vips.col_XYZ2scRGB(X, Y, Z)
Parameters:
  • X (float) – Input XYZ value

  • Y (float) – Input XYZ value

  • Z (float) – Input XYZ value

Returns:

R:

Return scRGB colour

G:

Return scRGB colour

B:

Return scRGB colour

Return type:

(int, R: float, G: float, B: float)

Turn XYZ into scRGB.

See also: vips_XYZ2scRGB().

Vips.col_ab2Ch(a, b, C, h)
Parameters:
Vips.col_ab2h(a, b)
Parameters:
Returns:

Hue (degrees)

Return type:

float

Vips.col_dE00(L1, a1, b1, L2, a2, b2)
Parameters:
  • L1 (float) – Input coordinate 1

  • a1 (float) – Input coordinate 1

  • b1 (float) – Input coordinate 1

  • L2 (float) – Input coordinate 2

  • a2 (float) – Input coordinate 2

  • b2 (float) – Input coordinate 2

Returns:

CIE dE2000 colour difference.

Return type:

float

CIEDE2000, from:

Luo, Cui, Rigg, “The Development of the CIE 2000 Colour-Difference Formula: CIEDE2000”, COLOR research and application, pp 340

Vips.col_make_tables_CMC()

Make the lookup tables for cmc.

Vips.col_sRGB2scRGB_16(r, g, b, R, G, B)
Parameters:
Return type:

int

Vips.col_sRGB2scRGB_16_noclip(r, g, b, R, G, B)
Parameters:
Return type:

int

Vips.col_sRGB2scRGB_8(r, g, b, R, G, B)
Parameters:
Return type:

int

Vips.col_sRGB2scRGB_8_noclip(r, g, b, R, G, B)
Parameters:
Return type:

int

Vips.col_scRGB2BW_16(R, G, B, g, og)
Parameters:
Return type:

int

Vips.col_scRGB2BW_8(R, G, B, g, og)
Parameters:
Return type:

int

Vips.col_scRGB2XYZ(R, G, B)
Parameters:
  • R (float) – Input scRGB value

  • G (float) – Input scRGB value

  • B (float) – Input scRGB value

Returns:

X:

Return XYZ colour

Y:

Return XYZ colour

Z:

Return XYZ colour

Return type:

(int, X: float, Y: float, Z: float)

Turn scRGB into XYZ.

See also: vips_scRGB2XYZ().

Vips.col_scRGB2sRGB_16(R, G, B, r, g, b, og)
Parameters:
Return type:

int

Vips.col_scRGB2sRGB_8(R, G, B, r, g, b, og)
Parameters:
Return type:

int

Vips.concurrency_get()
Returns:

number of worker threads to use.

Return type:

int

Returns the number of worker threads that vips should use when running a #VipsThreadPool.

vips gets this values from these sources in turn:

If Vips.concurrency_set() has been called, this value is used. The special value 0 means “default”. You can also use the command-line argument “–vips-concurrency” to set this value.

If Vips.concurrency_set() has not been called and no command-line argument was used, vips uses the value of the environment variable VIPS_CONCURRENCY,

If VIPS_CONCURRENCY has not been set, vips finds the number of hardware threads that the host machine can run in parallel and uses that value.

The final value is clipped to the range 1 - 1024.

See also: Vips.concurrency_get().

Vips.concurrency_set(concurrency)
Parameters:

concurrency (int) – number of threads to run

Sets the number of worker threads that vips should use when running a #VipsThreadPool.

The special value 0 means “default”. In this case, the number of threads is set by the environment variable VIPS_CONCURRENCY, or if that is not set, the number of threads available on the host machine.

See also: Vips.concurrency_get().

Vips.error_buffer()
Returns:

the error buffer as a C string which must not be freed

Return type:

str

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.

See also: Vips.error_clear().

Vips.error_buffer_copy()
Returns:

a copy of the libvips error buffer

Return type:

str

Return a copy of the vips error buffer, and clear it.

Vips.error_clear()

Clear and reset the error buffer. This is typically called after presenting an error to the user.

See also: Vips.error_buffer().

Vips.error_freeze()

Stop errors being logged. Use Vips.error_thaw() to unfreeze. You can nest freeze/thaw pairs.

Vips.error_g()
Raises:

GLib.Error

This function sets the glib error pointer from the vips error buffer and clears it. It’s handy for returning errors to glib functions from vips.

See Vips.g_error() for the inverse operation.

See also: g_set_error(), Vips.g_error().

Vips.error_thaw()

Re-enable error logging.

Vips.filename_get_filename(vips_filename)
Parameters:

vips_filename (str) – a filename including a set of options

Returns:

transfer full: just the filename component.

Return type:

str

Given a vips filename like “fred.jpg[Q=90]”, return a new string of just the filename part, “fred.jpg” in this case.

Useful for language bindings.

See also: Vips.filename_get_options().

Vips.filename_get_options(vips_filename)
Parameters:

vips_filename (str) – a filename including a set of options

Returns:

transfer full: just the options component.

Return type:

str

Given a vips filename like “fred.jpg[Q=90]”, return a new string of just the options part, “[Q=90]” in this case.

Useful for language bindings.

See also: Vips.filename_get_filename().

Vips.foreign_flags(loader, filename)
Parameters:
  • loader (str) – name of loader to use for test

  • filename (str) – file to test

Returns:

the flags for filename.

Return type:

Vips.ForeignFlags

Return the flags for filename using loader. loader is something like “tiffload” or “VipsForeignLoadTiff”.

Vips.format_sizeof(format)
Parameters:

format (Vips.BandFormat) – format type

Returns:

number of bytes for a band format.

Return type:

int

Vips.g_error()
Raises:

GLib.Error

This function adds the GLib.Error to the vips error buffer and clears it. It’s the opposite of Vips.error_g().

See also: Vips.error_g().

Vips.get_argv0()
Returns:

a pointer to an internal copy of the argv0 string passed to VIPS_INIT(). Do not free this value

Return type:

str

See also: VIPS_INIT().

Vips.get_disc_threshold()
Returns:

disc threshold in bytes.

Return type:

int

Return the number of bytes at which we flip between open via memory and open via disc. This defaults to 100mb, but can be changed with the VIPS_DISC_THRESHOLD environment variable or the –vips-disc-threshold command-line flag. See vips_image_new_from_file().

Vips.get_prgname()
Returns:

a pointer to an internal copy of the program name. Do not free this value

Return type:

str

Return the program name. This can be useful for the user tio see,.

See also: VIPS_INIT().

Vips.guess_libdir(argv0, env_name)
Parameters:
  • argv0 (str) – program name (typically argv[0])

  • env_name (str) – save prefix in this environment variable

Returns:

the libdir as a static string, do not free.

Return type:

str

Vips.guess_libdir() tries to guess the install directory (usually the configure libdir, or $prefix/lib). You should pass in the value of argv[0] (the name your program was run as) as a clue to help it out, plus the name of the environment variable you let the user override your package install area with (eg. “VIPSHOME”).

On success, Vips.guess_libdir() returns the libdir it discovered, and as a side effect, sets the prefix environment variable (if it’s not set).

Don’t free the return string!

See also: Vips.guess_prefix().

Vips.guess_prefix(argv0, env_name)
Parameters:
  • argv0 (str) – program name (typically argv[0])

  • env_name (str) – save prefix in this environment variable

Returns:

the install prefix as a static string, do not free.

Return type:

str

Vips.guess_prefix() tries to guess the install directory. You should pass in the value of argv[0] (the name your program was run as) as a clue to help it out, plus the name of the environment variable you let the user override your package install area with (eg. “VIPSHOME”).

On success, Vips.guess_prefix() returns the prefix it discovered, and as a side effect, sets the environment variable (if it’s not set).

Don’t free the return string!

See also: Vips.guess_libdir().

Vips.icc_is_compatible_profile(image, data, data_length)
Parameters:
Return type:

bool

Vips.icc_present()
Returns:

non-zero if the ICC library is present.

Return type:

int

VIPS can optionally be built without the ICC library. Use this function to test for its availability.

Vips.init(argv0)
Parameters:

argv0 (str) – name of application

Returns:

0 on success, -1 otherwise

Return type:

int

This function starts up libvips, see VIPS_INIT().

This function is for bindings which need to start up vips. C programs should use the VIPS_INIT() macro, which does some extra checks.

See also: VIPS_INIT().

Vips.interpretation_max_alpha(interpretation)
Parameters:

interpretation (Vips.Interpretation) – image interpretation

Returns:

the maximum alpha value for an interpretation.

Return type:

float

Vips.leak_set(leak)
Parameters:

leak (bool) – turn leak checking on or off

Turn on or off vips leak checking. See also –vips-leak, Vips.add_option_entries() and the VIPS_LEAK environment variable.

You should call this very early in your program.

Vips.malloc(object, size)
Parameters:
Returns:

a pointer to the allocated memory.

Return type:

object or None

GLib.malloc() local to object, that is, the memory will be automatically freed for you when the object is closed. If object is None, you need to free the memory explicitly with GLib.free().

This function cannot fail. See Vips.tracked_malloc() if you are allocating large amounts of memory.

See also: Vips.tracked_malloc().

Vips.nickname_find(type)
Parameters:

type (GObject.GType) – GObject.GType to search for

Returns:

the class nickname.

Return type:

str

Return the VIPS nickname for a GObject.GType. Handy for language bindings.

Vips.path_filename7(path)
Parameters:

path (str) – path to split

Return type:

str

Return the filename part of a vips7 path. For testing only.

Vips.path_mode7(path)
Parameters:

path (str) – path to split

Return type:

str

Return the mode part of a vips7 path. For testing only.

Vips.progress_set(progress)
Parameters:

progress (bool) – True to enable progress messages

If set, vips will print messages about the progress of computation to stdout. This can also be enabled with the –vips-progress option, or by setting the environment variable VIPS_PROGRESS.

Vips.pythagoras(L1, a1, b1, L2, a2, b2)
Parameters:
  • L1 (float) – Input coordinate 1

  • a1 (float) – Input coordinate 1

  • b1 (float) – Input coordinate 1

  • L2 (float) – Input coordinate 2

  • a2 (float) – Input coordinate 2

  • b2 (float) – Input coordinate 2

Return type:

float

Pythagorean distance between two points in colour space. Lab/XYZ/CMC etc.

Vips.shutdown()

Call this to drop caches, close plugins, terminate background threads, and finalize any internal library testing.

Vips.shutdown() is optional. If you don’t call it, your platform will clean up for you. The only negative consequences are that the leak checker and the profiler will not work.

You may call VIPS_INIT() many times and Vips.shutdown() many times, but you must not call VIPS_INIT() after Vips.shutdown(). In other words, you cannot stop and restart libvips.

See also: vips_profile_set(), Vips.leak_set().

Vips.strdup(object, str)
Parameters:
Returns:

a pointer to the allocated memory

Return type:

str

GLib.strdup() a string. When object is freed, the string will be freed for you. If object is None, you need to free the memory yourself with GLib.free().

This function cannot fail.

See also: Vips.malloc().

Vips.thread_shutdown()

Free any thread-private data and flush any profiling information.

This function needs to be called when a thread that has been using vips exits. It is called for you by Vips.shutdown() and for any threads created within the #VipsThreadPool.

You will need to call it from threads created in other ways or there will be memory leaks. If you do not call it, vips will generate a warning message.

It may be called many times, and you can continue using vips after calling it. Calling it too often will reduce performance.

Vips.tracked_aligned_alloc(size, align)
Parameters:
  • size (int) – number of bytes to allocate

  • align (int) – specifies the alignment

Returns:

a pointer to the allocated memory, or None on error.

Return type:

object or None

Allocate an area of memory aligned on a boundary specified by align that will be tracked by Vips.tracked_get_mem() and friends.

If allocation fails, Vips.tracked_aligned_alloc() returns None and sets an error message.

You must only free the memory returned with Vips.tracked_aligned_free().

See also: Vips.tracked_malloc(), Vips.tracked_aligned_free(), Vips.malloc().

Vips.tracked_aligned_free(s)
Parameters:

s (object or None) – memory to free

Only use it to free memory that was previously allocated with Vips.tracked_aligned_alloc() with a None first argument.

See also: Vips.tracked_aligned_alloc().

Vips.tracked_close(fd)
Parameters:

fd (int) – file to close()

Returns:

a file descriptor, or -1 on error.

Return type:

int

Exactly as close(2), but update the number of files currently open via Vips.tracked_get_files(). This is used by the vips operation cache to drop cache when the number of files available is low.

You must only close file descriptors opened with Vips.tracked_open().

See also: Vips.tracked_open(), Vips.tracked_get_files().

Vips.tracked_free(s)
Parameters:

s (object or None) – memory to free

Only use it to free memory that was previously allocated with Vips.tracked_malloc() with a None first argument.

See also: Vips.tracked_malloc().

Vips.tracked_get_allocs()
Returns:

the number of active allocations

Return type:

int

Returns the number of active allocations.

Vips.tracked_get_files()
Returns:

the number of open files

Return type:

int

Returns the number of open files.

Vips.tracked_get_mem()
Returns:

the number of currently allocated bytes

Return type:

int

Returns the number of bytes currently allocated via Vips.malloc() and friends. vips uses this figure to decide when to start dropping cache, see Vips.Operation.

Vips.tracked_get_mem_highwater()
Returns:

the largest number of currently allocated bytes

Return type:

int

Returns the largest number of bytes simultaneously allocated via Vips.tracked_malloc(). Handy for estimating max memory requirements for a program.

Vips.tracked_malloc(size)
Parameters:

size (int) – number of bytes to allocate

Returns:

a pointer to the allocated memory, or None on error.

Return type:

object or None

Allocate an area of memory that will be tracked by Vips.tracked_get_mem() and friends.

If allocation fails, Vips.tracked_malloc() returns None and sets an error message.

You must only free the memory returned with Vips.tracked_free().

See also: Vips.tracked_free(), Vips.malloc().

Vips.tracked_open(pathname, flags, mode)
Parameters:
  • pathname (str) – name of file to open

  • flags (int) – flags for open()

  • mode (int) – open mode

Returns:

a file descriptor, or -1 on error.

Return type:

int

Exactly as open(2), but the number of files currently open via Vips.tracked_open() is available via Vips.tracked_get_files(). This is used by the vips operation cache to drop cache when the number of files available is low.

You must only close the file descriptor with Vips.tracked_close().

pathname should be utf8.

See also: Vips.tracked_close(), Vips.tracked_get_files().

Vips.type_depth(type)
Parameters:

type (GObject.GType) –

Return type:

int

Vips.type_find(basename, nickname)
Parameters:
  • basename (str) – name of base class

  • nickname (str) – search for a class with this nickname

Returns:

the GObject.GType of the class, or 0 if the class is not found.

Return type:

GObject.GType

Search below basename, return the GObject.GType of the class whose name or nickname matches, or 0 for not found. If basename is None, the whole of Vips.Object is searched.

This function uses a cache, so it should be quick.

See also: Vips.class_find()

Vips.value_get_area(value)
Parameters:

value (GObject.Value) – get from this value

Returns:

The pointer held by value.

length:

optionally return length here

Return type:

(object or None, length: int)

Get the pointer from an area. Don’t touch count (area is static).

Vips.value_get_array(value)
Parameters:

value (GObject.Value) – GObject.Value to get from

Returns:

The array address.

n:

return the number of elements here, optionally

type:

return the type of each element here, optionally

sizeof_type:

return the sizeof each element here, optionally

Return type:

(object or None, n: int, type: GObject.GType, sizeof_type: int)

Return the pointer to the array held by value. Optionally return the other properties of the array in n, type, sizeof_type.

See also: Vips.value_set_array().

Vips.value_get_array_double(value)
Parameters:

value (GObject.Value) – GObject.Value to get from

Returns:

The array address.

Return type:

[float]

Return the start of the array of doubles held by value. optionally return the number of elements in n.

See also: Vips.ArrayDouble.new().

Vips.value_get_array_image(value)
Parameters:

value (GObject.Value) – GObject.Value to get from

Returns:

The array address.

Return type:

[Vips.Image]

Return the start of the array of images held by value. optionally return the number of elements in n.

See also: Vips.value_set_array_image().

Vips.value_get_array_int(value)
Parameters:

value (GObject.Value) – GObject.Value to get from

Returns:

The array address.

Return type:

[int]

Return the start of the array of ints held by value. optionally return the number of elements in n.

See also: Vips.ArrayInt.new().

Vips.value_get_blob(value)
Parameters:

value (GObject.Value) – GObject.Value to set

Returns:

The pointer held by value.

Return type:

bytes

Returns the data pointer from a blob. Optionally returns the length too.

blobs are things like ICC profiles or EXIF data. They are relocatable, and are saved to VIPS files for you coded as base64 inside the XML. They are copied by copying reference-counted pointers.

See also: Vips.value_set_blob()

Vips.value_get_ref_string(value)
Parameters:

value (GObject.Value) – GObject.Value to get from

Returns:

The C string held by value.

length:

return length here, optionally

Return type:

(str, length: int)

Get the C string held internally by the GObject.Value.

Vips.value_get_save_string(value)
Parameters:

value (GObject.Value) – GObject.Value to get from

Returns:

The C string held by value.

Return type:

str

Get the C string held internally by the GObject.Value.

Vips.value_is_null(psoec, value)
Parameters:
Return type:

bool

Vips.value_set_area(value, free_fn, *data)
Parameters:

Set value to be a ref-counted area of memory with a free function.

Vips.value_set_array(n, type, sizeof_type)
Parameters:
  • n (int) – number of elements

  • type (GObject.GType) – the type of each element

  • sizeof_type (int) – the sizeof each element

Returns:

GObject.Value to set

Return type:

value: GObject.Value

Set value to be an array of things.

This allocates memory but does not initialise the contents: get the pointer and write instead.

Vips.value_set_array_double(value, array)
Parameters:

Set value to hold a copy of array. Pass in the array length in n.

See also: Vips.ArrayDouble.get().

Vips.value_set_array_image(value, n)
Parameters:

Set value to hold an array of images. Pass in the array length in n.

See also: Vips.ArrayImage.get().

Vips.value_set_array_int(value, array)
Parameters:

Set value to hold a copy of array. Pass in the array length in n.

See also: Vips.ArrayInt.get().

Vips.value_set_array_object(n)
Parameters:

n (int) – the number of elements

Returns:

GObject.Value to set

Return type:

value: GObject.Value

Set value to hold an array of GObject.Object. Pass in the array length in n.

See also: vips_value_get_array_object().

Vips.value_set_blob(free_fn, data)
Parameters:
Returns:

GObject.Value to set

Return type:

value: GObject.Value

Sets value to hold a data. When value is freed, data will be freed with free_fn. value also holds a note of the size of the memory area.

blobs are things like ICC profiles or EXIF data. They are relocatable, and are saved to VIPS files for you coded as base64 inside the XML. They are copied by copying reference-counted pointers.

See also: Vips.value_get_blob()

Vips.value_set_blob_free(value, data)
Parameters:

Just like Vips.value_set_blob(), but when value is freed, data will be freed with GLib.free().

This can be easier to call for language bindings.

See also: Vips.value_set_blob()

Vips.value_set_ref_string(str)
Parameters:

str (str) – C string to copy into the GObject.Value

Returns:

GObject.Value to set

Return type:

value: GObject.Value

Copies the C string str into value.

vips_ref_string are immutable C strings that are copied between images by copying reference-counted pointers, making them much more efficient than regular GObject.Value strings.

str should be a valid utf-8 string.

Vips.value_set_save_string(str)
Parameters:

str (str) – C string to copy into the GObject.Value

Returns:

GObject.Value to set

Return type:

value: GObject.Value

Copies the C string into value.

str should be a valid utf-8 string.

Vips.version(flag)
Parameters:

flag (int) – which field of the version to get

Returns:

library version number

Return type:

int

Get the major, minor or micro library version, with flag values 0, 1 and 2.

Get the ABI current, revision and age (as used by Meson) with flag values 3, 4, 5.

Vips.version_string()
Returns:

a static version string

Return type:

str

Get the VIPS version as a static string, including a build date and time. Do not free.