diff --git a/doc/using-python.xml b/doc/using-python.xml index 864bab5a..f9a026cd 100644 --- a/doc/using-python.xml +++ b/doc/using-python.xml @@ -18,17 +18,45 @@ Introduction - VIPS comes with a convenient, high-level Python API based + VIPS comes with a convenient, high-level Python API built on on gobject-introspection. As long as you can get GOI - for your platform, you should be able to use vips. The - 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. This may already have happened, depending - on your platform. + for your platform, you should be able to use libvips. + To test the binding, start up Python and at the console enter: + + +>>> from gi.repository import Vips +>>> x = Vips.Image.new_from_file("/path/to/some/image/file.jpg") +>>> x.width +1450 +>>> + + + + + + If import fails, check you have the Python + gobject-introspection packages installed, that you have the + libvips typelib installed, and that the typelib is either + in the system area or on your GI_TYPELIB_PATH. + + + + + + If .new_from_file() fails, the vips overrides + have not been found. Make sure Vips.py is in + your system overrides area. + + + + + + + Here's a complete example program: + #!/usr/bin/python @@ -48,9 +76,7 @@ im = im.conv(mask) im.write_to_file(sys.argv[2]) - Reading this example, here's what happens when Python executes the - import line. Skip this list unless it's not working for you or you're - curious about the details: + When Python executes the import line: @@ -107,7 +133,7 @@ im.write_to_file(sys.argv[2]) - The next line loads the input file. You can append + The next line loads the input image. You can append load options to the argument list as keyword arguments, for example: @@ -164,9 +190,6 @@ im = im.similarity(scale = 0.9, interpolate = Vips.Interpolate.new("bicubic")) As noted above, the Python interface comes in two main parts, an automatically generated binding based on the vips typelib, plus a set of extra features provided by overrides. - - - The rest of this chapter runs through the features provided by the overrides.