VIPS from Python
3
VIPS Library
Using VIPS
How to use the VIPS library from Python
Using VIPS from Python
VIPS comes with a convenient, high-level Python API based
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
.
VIPS from Python example
#!/usr/bin/python
import sys
from gi.repository import Vips
im = Vips.Image.new_from_file(sys.argv[1])
im = im.crop(100, 100, im.width - 200, im.height - 200)
im = im.affine([0.9, 0, 0, 0.9])
mask = Vips.Image.new_from_array([[-1, -1, -1],
[-1, 16, -1],
[-1, -1, -1]], scale = 8)
im = im.conv(mask)
im.write_to_file(sys.argv[2])
Reading the example, the first line loads the input file. You can put load options after the
There are
several other constructors: you can load a formatted image (for example,
a JPEG format image) from a string with new_from_buffer()
pyvips8
Basics
Stuff.