68 lines
1.8 KiB
XML
68 lines
1.8 KiB
XML
<?xml version="1.0"?>
|
|
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
|
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
|
]>
|
|
<!-- set ts=2 sw=2 expandtab; retab -->
|
|
<refentry id="using-from-python">
|
|
<refmeta>
|
|
<refentrytitle>VIPS from Python</refentrytitle>
|
|
<manvolnum>3</manvolnum>
|
|
<refmiscinfo>VIPS Library</refmiscinfo>
|
|
</refmeta>
|
|
|
|
<refnamediv>
|
|
<refname>Using VIPS</refname>
|
|
<refpurpose>How to use the VIPS library from Python</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 id="using-python">
|
|
<title>Using VIPS from Python</title>
|
|
<para>
|
|
VIPS comes with a convenient, high-level Python API based
|
|
on <code>gobject-introspection</code>. 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.
|
|
</para>
|
|
|
|
<example>
|
|
<title>VIPS from Python example</title>
|
|
<programlisting language="Python">
|
|
#!/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])
|
|
</programlisting>
|
|
</example>
|
|
|
|
<para>
|
|
Reading the example, the first line loads the input file. There are
|
|
several other loaders: you can also load a formatted image (for example,
|
|
a JPEG format image)
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 id="python-basics">
|
|
<title><code>pyvips8</code> Basics</title>
|
|
<para>
|
|
Stuff.
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
</refentry>
|