Rust wrapper for gphoto2 (mirror of https://git.maxicarlos.de/maxicarlos08/gphoto2-rs)

Overview

GPhoto2-rs

Rust bindings to libgphoto2

What about gphoto-rs?

I know about the other crate (gphoto and gphoto2-sys which was created by @dcuddeback, but it is missing a lot of features which make the crate unusable for me, most notably the ability to change camera settings and in memory file download.
The author hasn't been active since 2017 regardless of numerous pull- and feature requests, so I made a new project with a more up to date rust code and all the features from libgphoto2.

Features

  • Camera
    • Capture images
    • Capture preview images
    • Download images
    • Get port information
    • Get abilities (model, driver stability, permissions, ...)
    • Read configuration
    • Set configuration
    • Interact with filesystem on camera
    • Camera events
    • Usb port information
  • Context
    • Autodetect camera
    • Get list of available cameras
    • Get camera by model and port

Gettings started

Installation

Run cargo add gphoto2 to add gphoto2 to your project or add this to your Cargo.toml:

[dependencies]
gphoto2 = "1"

Install libgphoto2

The libgphoto2 library must be installed on your system to use this library.

To install libgphoto2 on Debian based systems run:

sudo apt install libgphoto2-dev

On Arch systems run:

sudo pacman -S libgphoto2

On MacOS systems with Homebrew run:

homebrew install libgphoto2
Windows

There is no official way to install libgphoto2 on windows, but you can install it with MSYS2 (link to the package: mingw-w64-libgphoto2).

Basic Usage

This example takes a picture and saves it to disk

use gphoto2::Context;
use std::path::Path;

fn main() {
  // Everything starts from a context
  let context = Context::new().expect("Failed to create context");
  // From the context you can detect cameras
  let camera = context.autodetect_camera().expect("Failed to autodetect camera");

  // And take pictures
  let file_path = camera.capture_image().expect("Could not capture image");
  file_path
    .download(&camera, Path::new(&file_path.name().to_string()))
    .expect("Failed to download image");

  // For more advanced examples take a look at the examples/ foldeer
}

You can find more examples here

Stability

In general all all APIs should be stable, I've tested the ones my camera supported and found no bugs so far.
If you encounter an error like BAD_PARAMETERS or found a bug, please create an issue on GitHub.

License

Copyright © 2022 Maxicarlos08 [email protected]

This library uses the libgphoto2 library, which is licensed under the LGPL version 2.1.

You might also like...
By mirroring traffic to and from your machine, mirrord surrounds your local service with a mirror image of its cloud environment.
By mirroring traffic to and from your machine, mirrord surrounds your local service with a mirror image of its cloud environment.

mirrord lets you easily mirror traffic from your Kubernetes cluster to your development environment. It comes as both Visual Studio Code extension and

A mirror of lib.rs/main

Lib.rs (Crates.rs) Lib.rs is a fast, lightweight index of Rust libraries and applications. Crates published to crates.io will automatically show up on

 Video Management System. Mirror of Codeberg.
Video Management System. Mirror of Codeberg.

Screenshots | Changelog | Codeberg | Matrix Overview Full resolution live view with sub 2 second delay 24/7 recording to custom database TFlite object

A simple and adorable sysinfo utility. [Mirror]
A simple and adorable sysinfo utility. [Mirror]

bunbun A simple and adorable sysinfo utility written in Rust. Installation To build bunbun, you'll need Rust installed: $ git clone https://git.devraz

Tiny Rust CLI to checkout a recent git branch interactively
Tiny Rust CLI to checkout a recent git branch interactively

git-select-branch Tiny Rust CLI to checkout a recent git branch interactively. Installation Homebrew brew tap dnjstrom/git-select-branch brew install

Cli tool for git productivity written in Rust and packaged for consumption via NPM
Cli tool for git productivity written in Rust and packaged for consumption via NPM

crust 🍞 cli tool for git productivity written in Rust and packaged for consumption via NPM This repo is identical with @skyneticist/golee in terms of

A tiny crate to make it easy to share and apply Git hooks for Rust projects
A tiny crate to make it easy to share and apply Git hooks for Rust projects

Shareable git hooks for Rust project. Sloughi is a friend of Husky from North Africa! :algeria:

turbocommit is a Rust-based CLI tool that generates high-quality git commit messages in accordance with the Conventional Commits specification, using OpenAI's
turbocommit is a Rust-based CLI tool that generates high-quality git commit messages in accordance with the Conventional Commits specification, using OpenAI's

turbocommit is a Rust-based CLI tool that generates high-quality git commit messages in accordance with the Conventional Commits specification, using OpenAI's `gpt-3.5-turbo` language model. It is easy to use and a cost-effective way to keep git commit history at a higher quality, helping developers stay on track with their work.

An over-simplified version control system written in Rust, similar to Git, for local files (Incomplete)

Vault Vault will be a command line tool (if successful) similar to git which would have multiple features like brances etc etc. __ __ _ _

Comments
  • Investigate encodings and localisation

    Investigate encodings and localisation

    I've been looking a bit into how libgphoto2 deals with encodings, and found that it actually respects system localisation + some undocumented APIs for overriding localisation/encodings. What worries me there is that I'm not certain that non-English strings are guaranteed to be encoded in UTF-8 by libgphoto2, in which case perhaps we don't have a right to return them as String, or perhaps we at least have to customize encoding upon startup to enforce UTF-8 or something... As I said, I only started looking at this and there's a bit of uncertainty here. Now that I added test framework, I think it would be helpful to try and verify those assumptions and check what happens with non-ASCII characters.

    Originally posted by @RReverser in https://github.com/maxicarlos08/gphoto2-rs/issues/27#issuecomment-1262418828

    opened by RReverser 12
Releases(2.0)
  • 2.0(Oct 3, 2022)

    Breaking changes

    • Many methods now return a String instead of Cow<str>, for safety
    • The way widgets work has completely changes (@RReverser, #13)
    • Some methods that previously returned a Result are now Infallible (they return the value directly) (@RReverser, #17)
    • Some integer types have changed to prevent accuracy errors (@RReverser, #19)
    • Camera file content is now downloaded via CameraFS::download

    I'm sure I forgot some here, just expect your old code to not run with the new version

    Fixes

    • CamreaFS::ls_folder had a copy paste mistake (@RReverser, #14)
    • Bitmask enums where not handled correctly (@RReverser, #15)
    • Large structures have been put in a Box (@RReverser, #16)
    • Lock a mutex when calling libgphoto2 functions that are not thread-safe to work around libtool threading issues (@maxicarlos08, #24)
    • Fix some issues with CameraFile (@maxicarlos08, #21)
    • Fixed order of arguments in gp_camera_file_get_file (@gKodes)

    New features

    • The gphoto2 logging system has been hooked up to the rust one, this should make your debugging life easier (@RReverser, #26 and #29)
    • You can now set gphoto2 context progress functions (@maxicarlos08, #37)

    New Contributors

    • @gKodes made their first contribution in https://github.com/maxicarlos08/gphoto2-rs/pull/38

    Full Changelog: https://github.com/maxicarlos08/gphoto2-rs/compare/1.5.0...2.0

    Source code(tar.gz)
    Source code(zip)
  • 1.4.0(Sep 20, 2022)

    API changed:

    • InnerPtr/Inner are now AsRef/AsMut #8 (by @RReverser)
    • Some methods now return a String instead of Cow

    Bugs fixed:

    • Incorrect handling of bitfield enums #9 (by @RReverser)
    • C String stack-use-after-return #7
    • Incorrect usage of MaybeUninit #5 (by @RReverser)
    • Segfault in StorageInfo #4 (by @RReverser)
    Source code(tar.gz)
    Source code(zip)
  • 1.3.0(Aug 31, 2022)

    What's Changed

    • Add Windows support by @RReverser in https://github.com/maxicarlos08/gphoto2-rs/pull/2
    • Changed license to LGPL-v2.1 (#3)
    • Added Inner and InnerPtr traits which allow access to the inner libgphoto2 pointers (unsafe)

    New Contributors

    • @RReverser made their first contribution in https://github.com/maxicarlos08/gphoto2-rs/pull/2

    Full Changelog: https://github.com/maxicarlos08/gphoto2-rs/compare/1.2.0...1.3.0

    Source code(tar.gz)
    Source code(zip)
Owner
Maxicarlos08
"null"
Maxicarlos08
A Rust CLI tool that helps you enforce Git policies through Git hooks both server and client side

GitPolicyEnforcer This is a command line utility written in Rust, that helps you utilize Git hooks, to enforce various policies. It currently supports

Vagelis Prokopiou 4 Aug 14, 2022
git-cliff can generate changelog files from the Git history by utilizing conventional commits as well as regex-powered custom parsers.⛰️

git-cliff can generate changelog files from the Git history by utilizing conventional commits as well as regex-powered custom parsers. The changelog template can be customized with a configuration file to match the desired format.

Orhun Parmaksız 5k Jan 9, 2023
A git sub-command to view your git repository in the web browser

git-view A git sub-command to view your git repository in the web browser! About Are you also frustrated from moving your hands away from the keyboard

Hamothy 5 Sep 26, 2022
Git Explorer: cross-platform git workflow improvement tool inspired by Magit

Gex Git workflow improvement CLI tool inspired by Magit. This project is still under initial development, but I am actively dogfooding it and features

Peter Hebden 204 Jan 6, 2023
🌌⭐cosmo is a wrapper for Git essentially, allowing you to compress multiple commands into one

❯ Cosmo Git tooling of the future New feature: Cosmo hooks! Click here for more info! ❯ ?? Features Config files (with defaults!) Fast Easy to use Fri

Jack 1 Oct 31, 2021
A wrapper around the code action dump from https://mcdiamondfire.com.

DiamondFire Action Dump for Rust A wrapper around the code action dump from https://mcdiamondfire.com. This currently only provides schema types for u

null 3 Sep 17, 2022
A fast, efficient osu! beatmap mirror written in asynchronous Rust

A fast, efficient osu! beatmap mirror written in asynchronous Rust. Supports cheesegull, aswell as osu!api v2 formats.

James 4 Oct 28, 2022
An implementation of a mirror SponsorBlock server in Rust.

sponsorblock-mirror This is a Rust-based mirror of the SponsorBlock API. It also uses sb-mirror for mirroring the CSV dumps via rsync. Instances spons

Team Piped 38 Feb 11, 2023
Check the reproducibility status of your Arch Linux packages (read-only mirror)

arch-repro-status A CLI tool for querying the reproducibility status of the Arch Linux packages using data from a rebuilderd instance such as reproduc

Arch Linux 12 Nov 16, 2022
A library that creates a terminal-like window with feature-packed drawing of text and easy input handling. MIRROR.

BearLibTerminal provides a pseudoterminal window with a grid of character cells and a simple yet powerful API for flexible textual output and uncompli

Tommy Ettinger 43 Oct 31, 2022