Skip to main content

libgphoto2 bindings with an interface that strives to be idiomatic

Project description

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.

import gphoto2 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")

Currently only Python 2.7 and 3.4 (CPython and PyPy) are supported, however support for 2.6 and 3.3 is planned for the future.

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gphoto2-cffi-0.3.tar.gz (22.3 kB view details)

Uploaded Source

File details

Details for the file gphoto2-cffi-0.3.tar.gz.

File metadata

  • Download URL: gphoto2-cffi-0.3.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for gphoto2-cffi-0.3.tar.gz
Algorithm Hash digest
SHA256 876a3b815399f1d9f9b335bb9a914fbb25a622ba3fd6fe710fa44ca3ec04cbd7
MD5 cc861a6520e5aea8284d57a627b00b50
BLAKE2b-256 53759987dec9f6e1bc1940b4bfd0e9cdca4abb31a9b8f76db7f31ee8f7637823

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page