Top | Description | ![]() | ![]() | ![]() | ![]() |
#define | VIPS_INIT() |
int | vips_max_coord_get () |
int | vips_init () |
constchar * | vips_get_argv0 () |
constchar * | vips_get_prgname () |
void | vips_shutdown () |
void | vips_thread_shutdown () |
void | vips_add_option_entries () |
void | vips_leak_set () |
void | vips_block_untrusted_set () |
constchar * | vips_version_string () |
int | vips_version () |
constchar * | vips_guess_prefix () |
constchar * | vips_guess_libdir () |
Start VIPS up, shut VIPS down, get version information, relocation.
VIPS is a relocatable package, meaning you can move the directory tree youcompiled it to at runtime and it will still be able to find all data files.This is required for OS X and Windows, but slightly unusual in the Unixworld. Seevips_init()
andvips_guess_prefix()
.
#define VIPS_INIT(ARGV0)
VIPS_INIT() starts up the world of VIPS. You should call this onprogram startup before using any other VIPS operations. If you do not callVIPS_INIT()
, VIPS will call it for you when you use your first VIPSoperation, but it may not be able to get hold ofARGV0
and VIPS maytherefore be unable to find its data files. It is much better to callthis macro yourself.
ARGV0
is used to help discover message catalogues if libvips has beenrelocated. If you don't need a relocatable package, you can just pass""
and it'll be fine.
Additionally,VIPS_INIT()
can be run from any thread, but it must not becalled from more than one thread at the same time. This is much easier toguarantee if you call it yourself.
VIPS_INIT() is a macro, since it tries to check ABI compatibilitybetween the caller and the library. You can also callvips_init()
, thenon-macro version, if macros are not available to you.
You may callVIPS_INIT()
many times andvips_shutdown()
many times, but youmust not callVIPS_INIT()
aftervips_shutdown()
. In other words, you cannotstop and restart vips.
Use the environment variableVIPS_MIN_STACK_SIZE
to set the minimum stacksize. For example,2m
for a minimum of two megabytes of stack. This canbe important for systems like musl where the default stack is very small.
VIPS_INIT() does approximately the following:
checks that the libvips your program is expecting isbinary-compatible with the vips library you're running against
sets a minimum stack size, see above
initialises any libraries that VIPS is using, including GObjectand the threading system, if necessary
guesses where the VIPS data files are and sets upinternationalisation --- seevips_guess_prefix()
creates the main vips types, includingVipsImage and friends
loads any plugins from $libdir/vips-x.y/, where x and y are themajor and minor version numbers for this VIPS.
Example:
123456789 | intmain(intargc,char**argv){if(VIPS_INIT(argv[0]))vips_error_exit("unable to start VIPS");vips_shutdown();return0;} |
See also:vips_shutdown()
,vips_add_option_entries()
,vips_version()
,vips_guess_prefix()
,vips_guess_libdir()
.
intvips_max_coord_get (void
);
Return the maximum coordinate value. This can be the default, a value setset by the--vips-max-coord
CLI arg, or a value set in theVIPS_MAX_COORD
environment variable.
These strings can include unit specifiers, eg. "10m" for 10 million pixels.Values above INT_MAX are not supported.
intvips_init (constchar *argv0
);
This function starts up libvips, seeVIPS_INIT()
.
This function is for bindings which need to start up vips. C programsshould use theVIPS_INIT()
macro, which does some extra checks.
See also:VIPS_INIT()
.
constchar *vips_get_argv0 (void
);
See also:VIPS_INIT()
.
a pointer to an internal copy of theargv0 string passed toVIPS_INIT()
. Do not free this value.
constchar *vips_get_prgname (void
);
Return the program name. This can be useful for the user tio see,.
See also:VIPS_INIT()
.
voidvips_shutdown (void
);
Call this to drop caches, close plugins, terminate background threads, andfinalize any internal library testing.
vips_shutdown() is optional. If you don't call it, your platform willclean up for you. The only negative consequences are that the leak checkerand the profiler will not work.
You may callVIPS_INIT()
many times andvips_shutdown()
many times, but youmust not callVIPS_INIT()
aftervips_shutdown()
. In other words, you cannotstop and restart libvips.
See also:vips_profile_set()
,vips_leak_set()
.
voidvips_thread_shutdown (void
);
Free any thread-private data and flush any profiling information.
This function needs to be called when a thread that has been using vipsexits. It is called for you byvips_shutdown()
and for any threads createdwithin theVipsThreadPool.
You will need to call it from threads created inother ways or there will be memory leaks. If you do not call it, vipswill generate a warning message.
It may be called many times, and you can continue using vips aftercalling it. Calling it too often will reduce performance.
voidvips_add_option_entries (GOptionGroup *option_group
);
Add the standard vipsGOptionEntry
to aGOptionGroup
.
See also:g_option_group_new()
.
voidvips_leak_set (gboolean leak
);
Turn on or off vips leak checking. See also --vips-leak,vips_add_option_entries()
and theVIPS_LEAK
environment variable.
You should call this very early in your program.
voidvips_block_untrusted_set (gboolean state
);
Set the block state on all untrusted operations.
1 | vips_block_untrusted_set(TRUE); |
Will block all untrusted operations from running.
Usevips -l
at the command-line to see the class hierarchy and whichoperations are marked as untrusted.
Set the environment variableVIPS_BLOCK_UNTRUSTED
to block all untrustedoperations onvips_init()
.
constchar *vips_version_string (void
);
Get the VIPS version as a static string, including a build date and time.Do not free.
intvips_version (int flag
);
Get the major, minor or micro library version, withflag
values 0, 1 and2.
Get the ABI current, revision and age (as used by Meson) withflag
values 3, 4, 5.
constchar *vips_guess_prefix (constchar *argv0
,constchar *env_name
);
vips_guess_prefix() tries to guess the install directory. You should passin the value of argv[0] (the name your program was run as) as a clue tohelp it out, plus the name of the environment variable you let the useroverride your package install area with (eg. "VIPSHOME").
On success,vips_guess_prefix()
returns the prefix it discovered, and as aside effect, sets the environment variable (if it's not set).
Don't free the return string!
See also:vips_guess_libdir()
.
constchar *vips_guess_libdir (constchar *argv0
,constchar *env_name
);
vips_guess_libdir() tries to guess the install directory (usually theconfigure libdir, or $prefix/lib). You should passin the value of argv[0] (the name your program was run as) as a clue tohelp it out, plus the name of the environment variable you let the useroverride your package install area with (eg. "VIPSHOME").
On success,vips_guess_libdir()
returns the libdir it discovered, and as aside effect, sets the prefix environment variable (if it's not set).
Don't free the return string!
See also:vips_guess_prefix()
.