updates notes on binding vips

This commit is contained in:
John Cupitt 2014-11-17 14:23:25 +00:00
parent 240f0f1fd2
commit 759682ef8a

View File

@ -38,40 +38,30 @@ from gi.repository import Vips
libvips used in this way is likely to be rather bare-bones. For Python, libvips used in this way is likely to be rather bare-bones. For Python,
we wrote a set of overrides which layer a more Pythonesque interface we wrote a set of overrides which layer a more Pythonesque interface
on top of the one provided for libvips by pygobject. These overrides on top of the one provided for libvips by pygobject. These overrides
are simply a set of Python classes, there's no magic. You are likely are simply a set of Python classes.
to want to do the same for your language.
</para> </para>
<para> <para>
A second problem is that the libvips C API makes heavy use of varargs to To call a vips operation, you'll need to make a new operation with
pass optional parameters to operations. For example, in C you can write: vips_operation_new() (all it does is look up the operation by name
with vips_type_find(), then call g_object_new() for you), then
<programlisting language="C"> use vips_argument_map() and friends to loop over the operation's
VipsImage *in = vips_image_new_from_file (filename, NULL); arguments setting them. Once you have set all arguments, use
VipsImage *out; vips_cache_operation_build() to look up the operation in the cache
and either build or dup it. If something goes wrong, you'll need
vips_embed(in, &amp;out, 10, 10, 100, 100, to use vips_object_unref_outputs() and g_object_unref() to free the
"extend", VIPS_EXTEND_COPY, partially-built object.
NULL); The Python binding uses this technique to implement a function which
</programlisting> can call any vips operation, turning optional vips arguments into
Python keyword arguments.
to call <code>embed</code> with the optional parameter
<code>extend</code>. varargs parameter lists are not supported by
gobject-introspection, so you'll need to find some other way to call
<code>embed</code>.
</para> </para>
<para> <para>
If you are writing a language binding, you won't need these. Instead, make If your language does not have a gobject-introspection package, you'll
a new operation with vips_operation_new() (all it does is look up the need to write something in C or C++ doing approximately the same thing.
operation by name with vips_type_find(), then call g_object_new() for you), The C++ API takes this route.
then use vips_argument_map() and friends to loop over the operation's
arguments setting them. Once you have set all arguments, use
vips_cache_operation_build() to look up the operation in the cache and
either build or dup it. If something goes wrong, you'll need to use
vips_object_unref_outputs() and g_object_unref() to free the
partially-built object.
</para> </para>
</refsect1> </refsect1>
</refentry> </refentry>