Skip to main content

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 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.

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

Release files for gphoto2-cffi 0.4.2

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

Source distribution (sdist)

Source distribution for gphoto2-cffi 0.4.2
File Size Uploaded
gphoto2-cffi-0.4.2.tar.gz 22.9 kB Details

Release files / gphoto2-cffi-0.4.2.tar.gz

Download URL gphoto2-cffi-0.4.2.tar.gz
Size 22.9 kB
Tags Source
SHA-256 checksum
How to use checksums
281f3c1b4113784f86170fe87b013663889066fd0dc23bc9c1c491d5e99f3438
BLAKE2b-256 checksum
How to use checksums
4281b742c2e09988c0e0cbb8c0888f0021e7f7dbc90a40a14f93d2718854d2ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.4.2 This release

1 release file

0.4.1

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

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