File: README.rst

package info (click to toggle)
gphoto2-cffi 0.4.3~a1-1.1
  • links: PTS
  • area: main
  • in suites: bullseye, sid
  • size: 172 kB
  • sloc: python: 849; makefile: 147
file content (67 lines) | stat: -rw-r--r-- 1,859 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
gphoto2-cffi
============

Python bindings for `libgphoto2`_ with an interface that strives to be
idiomatic. In contrast to other bindings for Python, gphoto2-cffi hides most
of the lower-level abstractions and reduces the API surface while still
offering access to most of the library's features.

.. code:: python

    import gphoto2cffi as gp

    # List all attached cameras that are supported
    cams = gp.list_cameras()

    # Get a camera instance by specifying a USB bus and device number
    my_cam = gp.Camera(bus=4, device=1)

    # Get an instance for the first supported camera
    my_cam = gp.Camera()
    # or
    my_cam = next(gp.list_cameras())

    # Capture an image to the camera's RAM and get its data
    imgdata = my_cam.capture()

    # Grab a preview from the camera
    previewdata = my_cam.get_preview()

    # Get a list of files on the camera
    files = tuple(my_cam.list_all_files())

    # Iterate over a file's content
    with open("image.jpg", "wb") as fp:
        for chunk in my_cam.files[0].iter_data():
            fp.write(chunk)

    # Get a configuration value
    image_quality = my_cam.config['capturesettings']['imagequality'].value
    # Set a configuration value
    my_cam.config['capturesettings']['imagequality'].set("JPEG Fine")

Python 2.7 and 3.4 or newer (CPython and PyPy) are supported.

.. _libgphoto2: http://www.gphoto.org/proj/libgphoto2/
.. _PyPy: http://pypy.org/
.. _cffi: https://cffi.readthedocs.org/

Requirements
------------

* libgphoto2 with development headers
* A working C compiler
* cffi

Installation
------------

From Source::

    $ pip install git+https://github.com/jbaiter/gphoto2-cffi.git

Similar projects
----------------

* `piggyphoto <https://github.com/alexdu/piggyphoto>`_: Uses ctypes
* `python-gphoto2 <https://github.com/jim-easterbrook/python-gphoto2>`_: Uses SWIG