diff --git a/doc/reference/using-python.xml b/doc/reference/using-python.xml
index 56b24cfd..2b658ba0 100644
--- a/doc/reference/using-python.xml
+++ b/doc/reference/using-python.xml
@@ -24,7 +24,8 @@
Vips.py
file
needs to be copied to the overrides directory of your GOI install,
and you need to have the vips typelib on your
- GI_TYPELIB_PATH
.
+ GI_TYPELIB_PATH
. This may already have happened, depending
+ on your platform.
@@ -41,7 +42,7 @@ im = Vips.Image.new_from_file(sys.argv[1])
im = im.extract_area(100, 100, im.width - 200, im.height - 200)
im = im.similarity(scale = 0.9)
mask = Vips.Image.new_from_array([[-1, -1, -1],
- [-1, 16, -1],
+ [-1, 16, -1],
[-1, -1, -1]], scale = 8)
im = im.conv(mask)
@@ -109,9 +110,9 @@ im = im.similarity(scale = 0.9, interpolate = Vips.Interpolate.new("bicubic"))
The Python interface comes in two main parts. First, the C source code
to libvips has been marked up with special comments describing the
- internals in a standard way. These comments are read by
+ interface in a standard way. These comments are read by
gobject-introspection when libvips is compiled and used to generate a
- typelib, a description of the library's internals. When your Python
+ typelib, a description of how to call the library. When your Python
program starts, the import line:
@@ -133,10 +134,9 @@ from gi.repository import Vips
These overrides do the following things:
+
-
- Automatic wrapping of vips operations
-
+ Automatic wrapping of vips operations
It intercepts member lookup
@@ -148,18 +148,37 @@ from gi.repository import Vips
+ Add docstrings
+
- Automatic wrapping of operation arguments. The first input image
- argument becomes the self
argument. If there are no
- input image arguments, the operation appears as a class member.
- Optional input
- arguments become keyword arguments. The result is a list of all
- the output arguments, or a single output if there is only one.
+ Try help(Vips.Image)
, or something like:
+
+
+image = Vips.Image.new_from_file("x.jpg")
+help(image.add)
+
+
+ For any operator it'll list the required and optional input and
+ output arguments, using all the rules listed below. This plus the
+ C API docs should be enough to answer most questions. IDEs should
+ display the help text automatically as you work.
-
+
+
+
+ Automatic wrapping of operation arguments
+
- Optional output arguments are enabled with a boolean keyword
- argument of that name. For example, "min" (the operation which
+ The first input image argument becomes the self
+ argument. If there are no input image arguments, the operation
+ appears as a class member. Optional input arguments become
+ keyword arguments. The result is a list of all the output
+ arguments, or a single output if there is only one.
+
+
+
+ Optional output arguments are enabled with a boolean keyword
+ argument of that name. For example, "min" (the operation which
appears in the C API as vips_min()), can be called like this:
@@ -174,6 +193,9 @@ min_value = im.min()
min_value, x_pos, y_pos = im.min(x = True, y = True)
+
+ Although in this case, the .minpos()
convenience
+ function would be simpler.
@@ -253,7 +275,8 @@ result_image = image1.bandjoin([image2, 255])
The wrapper spots errors from vips operations and raises the
Vips.Error
exception. You can catch it in the
- usual way.
+ usual way. The .detail
member gives the detailed
+ error message.
@@ -286,6 +309,8 @@ result_image = image.math(Vips.OperationMath.SIN)
result_image = image.sin()
+
+ See help(Vips.Image)
for a list.
@@ -297,6 +322,7 @@ result_image = image.sin()
.get_value()
, .set_value()
.bandsplit()
, .maxpos()
.minpos()
.
+ Again, see help(Vips.Image)
for a list.