Skip to main content
Build Status

This module wraps the libvips image processing library. It needs the libvips shared library on your library search path, version 8.2 or later.

https://jcupitt.github.io/libvips

This binding passes the vips test suite cleanly and with no leaks under python2.7 - python3.6, pypy and pypy3 on Windows, macOS and Linux.

We have formatted docs online here:

https://jcupitt.github.io/pyvips/

How it works

Programs that use pyvips don’t manipulate images directly, instead they create pipelines of image processing operations building on a source image. When the end of the pipe is connected to a destination, the whole pipeline executes at once, streaming the image in parallel from source to destination a section at a time.

Because pyvips is parallel, it’s quick, and because it doesn’t need to keep entire images in memory, it’s light. For example, the libvips speed and memory use benchmark:

https://github.com/jcupitt/libvips/wiki/Speed-and-memory-use

Loads a large tiff image, shrinks by 10%, sharpens, and saves again. On this test pyvips is typically 5x faster than Pillow-SIMD and needs 4x less memory.

There’s a handy blog post explaining how libvips opens files, which gives some more background.

http://libvips.blogspot.co.uk/2012/06/how-libvips-opens-file.html

Install

You need the libvips shared library on your library search path, version 8.2 or later. On linux, you can install via your package manager; on Windows you can download a pre-compiled binary from the libvips website:

https://jcupitt.github.io/libvips/

Then just install this package, perhaps:

$ pip install pyvips

Example

This sample program loads a JPG image, doubles the value of every green pixel, sharpens, and then writes the image back to the filesystem again:

import pyvips

image = pyvips.Image.new_from_file('some-image.jpg', access='sequential')
image *= [1, 2, 1]
mask = pyvips.Image.new_from_array([[-1, -1, -1],
                                    [-1, 16, -1],
                                    [-1, -1, -1]
                                   ], scale=8)
image = image.conv(mask, precision='integer')
image.write_to_file('x.jpg')

Converting old code

To convert old code, replace the lines:

import gi
gi.require_version('Vips', '8.0')
from gi.repository import Vips

with:

import pyvips
Vips = pyvips

Instead of the pyvips = Vips, you can of course also swap all Vips for pyvips with eg.:

%s/Vips/pyvips/g

Background

This is supposed to be an experiment with making a libvips binding using cffi.

http://cffi.readthedocs.io/en/latest/ref.html

The Python binding included in libvips works, but porting and installation are more difficult than they should be.

The hope is that a new Python binding on top of cffi would be:

  • compatible with the current Python binding (it should run the same test suite, unmodified)

  • easier to install, since the stack would be much smaller, and there would be no issues with the overrides directory

  • faster, since we could implement Buffer and save some copies

  • faster, since we could make it “thinner”. The ffi Ruby binding is about twice as fast as the gobject-introspection one, when running the test suite

  • portable across CPython, PyPy and others

  • more simply portable to Windows

  • easy to package for pip

Notes

Local user install:

$ pip install --user -e .
$ pip3 install --user -e .
$ pypy -m pip --user -e .

Run test suite:

$ nosetests --logging-level=WARNING
$ python3 -m nose --logging-level=WARNING
$ pypy -m nose --logging-level=WARNING

Stylecheck:

$ flake8

Generate HTML docs in doc/build/html:

$ cd doc; sphinx-build -bhtml . build/html

Regenerate autodocs:

$ cd doc; \
  python -c "import pyvips; pyvips.Operation.generate_sphinx_all()" > x

And copy-paste x into the obvious place in doc/vimage.rst.

Metadata

Release files for pyvips 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for pyvips 2.0.0
File Interpreter ABI Platform
pyvips-2.0.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Release files / pyvips-2.0.0-py2.py3-none-any.whl

Download URL pyvips-2.0.0-py2.py3-none-any.whl
Size 55.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
c99590364cfc620af0db004aa9c6e6830a3c337d0db074d0a61da74dd4b91071
BLAKE2b-256 checksum
How to use checksums
6a2d5ca1ee5077f733335c208b7a3f3d62f964aaab87731ab3e2850e404df7f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

3.2.0

1 release file

3.1.1

1 release file

3.1.0

1 release file

3.0.0

1 release file

2.2.3

1 release file

2.2.2

1 release file

2.2.1

1 release file

2.2.0

1 release file

2.1.16

1 release file

2.1.15

1 release file

2.1.14

1 release file

2.1.13

1 release file

2.1.12

1 release file

2.1.11

1 release file

2.1.10

1 release file

2.1.8

1 release file

2.1.7

1 release file

2.1.6

1 release file

2.1.5

1 release file

2.1.4

1 release file

2.1.3

1 release file

2.1.2

1 release file

2.1.1

1 release file

2.1.0

2 release files

2.0.5

1 release file

2.0.4

1 release file

2.0.3

1 release file

2.0.2

1 release file

2.0.1

1 release file

This release

2.0.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page