Sunday, March 13, 2011

How-to: A gphoto primer

A few years back, my time lapse video of the Portage Lake lift bridge at sunset turned out to be rather popular -- because of my brief tutorial on using gphoto2 for time-lapse video. So, I've written up a short (but more detailed) tutorial on setting up and using gphoto for time-lapse videos.

Warning! (October 2019): This post is quite out-of-date. I now use a camera with a built-in intervalometer and haven't had to wrangle gphoto2 in years. The instructions below might work -- or might not. They were last updated in March 2015.

Step 1: Install gphoto
The first step is getting gphoto installed on your computer. How exactly you do this depends on your operating system.

Mac OS X: While this isn't quite download-and-go, it is still fairly easy to install gphoto2 on Mac OS X. The first step is to install MacPorts, a package manager for Mac OS X. You can begin at the MacPorts installation page, skipping down to the "Mac OS X Package (.pkg) Installer" section. Click on the link in the first paragraph which corresponds to your system. Download, open, and run the installer. Once it is done, open a Terminal window and type:

sudo port -v selfupdate

This may take a while. Once MacPorts is done, type:

sudo port install gphoto2

this will take a while. Leave the computer alone, have some coffee, read a book. When the compiler is done, you'll have a working copy of gphoto2 and everything you need to make it work (on the computer side, at least)!

Good news for OS X programmers: In the comments, Andreas writes that he has put together a framework for Mac OS X programmers, which can be used directly in XCode. I haven't tried this myself -- and of course, always be careful with unknown code -- but if you're interested, you can find it here:

Linux: If you are using Linux, you almost certainly know enough to install gphoto on your own -- your favorite package manager will work. Versions of gphoto2 are available for all major package managers. For example:

    sudo apt-get install gphoto2

Windows: Unfortunately for Windows users, there is no official version of gphoto for windows. In fact, the gphoto2 team has a few words to say on the matter. I have heard rumors of an unofficial version of gphoto for Windows, but finding and getting that set up is far beyond the scope of this tutorial.

Step 2: Set up and test your camera
Almost all digital cameras made in the last 10 years -- whether point-and-shoot or DSLR -- will almost certainly work with gphoto. To be sure, you can check out this complete list of supported cameras.

There are a few basic steps to getting your camera ready to work with gphoto:
  1. Set your camera to the correct connection mode. This isn't the exposure mode, but rather the mode which controls how your camera talks to your computer. To figure out which mode you need, look on the list of supported cameras. Find your camera in the list, and look for the text in parentheses at the end -- for example "(PTP mode)". You now need to change your camera into this mode. This is usually in a "setup" or "options" menu, and it's a rarely changed option. Every camera is different, and your best resource is the user's guide. Many cameras work in either their normal mode (requiring no special setup), or PTP mode, which is a standard allowing computers to control cameras.

    Here's an example for the Nikon D40x (my favorite camera) which works on most Nikon DSLRs. The mode you need is PTP mode. To set this, press the Menu button, then choose "Setup", then "USB", then "MTP/PTP" and hit OK.
  2. Connect your camera to a computer using a USB cable. This should be the normal USB cable which you use to connect your camera to your computer when downloading photos. If you normally use a card reader or some other method, you will need to locate a USB cable which lets you connect your camera directly to the computer -- typically cameras come pre-supplied with these. I recommend using a laptop, so that you can move the camera to your favorite shooting location.
  3. For Mac OS X users only: kill the PTP daemon. This isn't as evil as it sounds! Mac OS X automatically "grabs" the camera when you plug it in -- this is how iPhoto and other programs can automatically download your photos. But this also means that gphoto doesn't "own" the camera, and can't use it. To fix this, open Terminal and type:
    killall PTPCamera
    You will have to repeat this entire process every time you plug the camera in to your laptop, or if you turn the camera off and on again while attached to your computer. In fact, killing the PTP daemon is the answer to many weird gphoto errors on Mac OS X.
  4. Test that your camera is connected and working. To do so, execute this command in a terminal:
    gphoto2 --capture-image
    Your camera should (after a few seconds) take a photo, just as if you had pressed the shutter button. If it doesn't, the error message may be enlightening.

Step 3: Take photos!
You are now all ready to take photos! The most useful "advanced" feature of gphoto2 is the ability to take time-lapse photos. The basic command you need will look like this:
     gphoto2 --capture-image-and-download --interval=30 --frames=10
Here's a breakdown:
  • --capture-image: tells gphoto to take an image.
  • --interval=30 : tells gphoto to keep taking images, once every 30 seconds.
  • --frames=10 : tells gphoto to stop taking photos after 10 have been captured (leave this off to continue forever).

You can replace --capture-image-and-download with --capture-image if you want the images to be kept on the camera. (This completely fails to work on my Nikon D40x).  Remember, you don't want to touch the camera while it's taking shots!

Here are a handful of useful things to remember:
  • Your camera will take photos in the current exposure mode (Program, Aperture Priority, etc.). Be sure your camera is in the mode you want before you begin. This usually means going into full-manual mode, so that the exposure is consistent between frames. It is also possible to use gphoto2 to change your exposure mode on some cameras.
  • If using a camera with ISO-Auto, ADR, etc., turn it off. These features can change your intended exposure and make your frames look inconsistent, even if you're in fully manual exposure mode.
  • Focus your camera on the intended subject before you begin, and then turn your lens to manual focus. This will avoid the camera trying to refocus for each frame, especially if there are moving objects involved, or if lighting gets dim.
  • Don't touch your camera while taking time-lapse photos, unless you want different frames to have a different viewpoint. For time-lapse videos such as the one I mentioned at the top of this post, you want the camera to be untouched for the entire time.

Those are the basics! You can do a lot more than this with gphoto2 -- but that's for the future. If you're interested in seeing what you can do, there are many other tutorials available out on the web. You can also get a summary of gphoto's options by typing
   gphoto2 --help
in your terminal. For now, enjoy!

Appendix: Installing gphoto2 on Mac OS X, the hard way

For those interested in how we had to do things "back in the day", I'm keeping the information below: how to get the latest version of gphoto2 and libgphoto2 to install under Mac OS X. This is no longer necessary, because MacPorts currently has the newest version of gphoto. Read above for more information. And with that, here's the old data:

Here are more detailed instructions for installing the newest version of gphoto2 on Mac OS X. I recommend starting with the MacPorts version above -- even though it's old, installing it will also install and update many other programs which gphoto2 needs to operate. After doing that, you should get the newest version. To get the newest version, download both the gphoto and libgphoto packages from the gphoto homepage. The first step is to install libgphoto. Double-click the libgphoto package to uncompress it. In Terminal, type the following commands:
 cd (path to the libgphoto directory)
 sudo ./configure --prefix=/opt/local
A large amount of text should pass through the terminal, after which type
 sudo make
 sudo make install
This installs libgphoto. The next step is to install gphoto2 itself, which uses libgphoto to control your camera. Double-click the gphoto package to uncompress it. Again in Terminal, type the following commands:
 cd (path to the gphoto directory)
 sudo ./configure --prefix=/opt/local --without-cdk --without-aalib POPT_CFLAGS="-I${prefix}/include" POPT_LIBS="-L${prefix}/lib -lpopt"
 sudo make
 sudo make install
These should configure, compile, and install gphoto2 correctly. To double-check that it worked, type in Terminal:
 gphoto2 -v
The result should be a bit of information, including version numbers about gphoto2. If there are any errors, you'll need to reinstall gphoto2.


Summer said...

My Olympus digital SLR is not supported, but my tiny "purse camera" Canon PowerShot is. How weird is that? Now I'll have to try this... shucks & darn;-)

Spoon (Jim Lind) said...

Thanks for the quick overview. This was enough for me to get my gPhoto install capturing. Couldn't get the upgrade to install, but I'll live with the version from MacPorts.

Anonymous said...

This is very useful! Thank you.
Unfortunately I got and error after configure with make
Can you help?

Paul-MBP-4:_libgphoto2 paul$ make
make all-recursive
Making all in libgphoto2_port
make all-recursive
Making all in po
make[4]: Nothing to be done for `all'.
Making all in libgphoto2_port
/bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I. -I.. -DLOCALEDIR=\"/usr/local/share/locale\" -DIOLIBS=\"/usr/local/lib/libgphoto2_port/0.8.0\" -Wall -Wmissing-declarations -Wmissing-prototypes -g -D_GPHOTO2_INTERNAL_CODE -g -O2 -g -O2 -MT libgphoto2_port_la-gphoto2-port-info-list.lo -MD -MP -MF .deps/libgphoto2_port_la-gphoto2-port-info-list.Tpo -c -o libgphoto2_port_la-gphoto2-port-info-list.lo `test -f 'gphoto2-port-info-list.c' || echo './'`gphoto2-port-info-list.c
mkdir .libs
gcc -DHAVE_CONFIG_H -I. -I.. -I. -I.. -DLOCALEDIR=\"/usr/local/share/locale\" -DIOLIBS=\"/usr/local/lib/libgphoto2_port/0.8.0\" -Wall -Wmissing-declarations -Wmissing-prototypes -g -D_GPHOTO2_INTERNAL_CODE -g -O2 -g -O2 -MT libgphoto2_port_la-gphoto2-port-info-list.lo -MD -MP -MF .deps/libgphoto2_port_la-gphoto2-port-info-list.Tpo -c gphoto2-port-info-list.c -fno-common -DPIC -o .libs/libgphoto2_port_la-gphoto2-port-info-list.o
gphoto2-port-info-list.c: In function 'gp_port_info_list_new':
gphoto2-port-info-list.c:122: warning: statement with no effect
gphoto2-port-info-list.c: At top level:
gphoto2-port-info-list.c:505: fatal error: opening dependency file .deps/libgphoto2_port_la-gphoto2-port-info-list.Tpo: Permission denied
compilation terminated.
make[4]: *** [libgphoto2_port_la-gphoto2-port-info-list.lo] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

DC said...

@Paul Godard: Looks like you typed 'make', instead of 'sudo make'. The 'sudo' is very important, because most of the installation requires administrator privileges. Even if your account is an administrator, you have to begin privileged commands with 'sudo' to instruct the computer to allow you that access. (You'll have to type in your password too.)

If that doesn't work, let me know!

Anonymous said...
This comment has been removed by the author.
Anonymous said...

Yes obviously it was too late last night!
Thank you David.
It is now 'making' something with a lot of text display... all these camers I don't need... anyway.
make & make install done with sudo of course.
However, I have the impression something does not work correctly (updating to 2.4.8). I have uploaded the log on my server :
Anyway, gphoto2 is installed correctly :
This version of gphoto2 is using the following software versions and options:
gphoto2 2.4.4 /usr/bin/gcc-4.0, popt(m), exif, no cdk, no aa, jpeg, readline
libgphoto2 2.4.5 /usr/bin/gcc-4.0, ltdl, EXIF
libgphoto2_port 0.8.0 /usr/bin/gcc-4.0, ltdl, USB, serial without locking
Now it seems that I can not find the process to kill :
ps -auxc | grep PTP
ps: No user named 'xc'
What is the next step?

Anonymous said...

I figured that xc had to be replaced by userid. It worked but then gphoto2 still does not want to work...step by step... error aftererror!
Paul-MBP-4:_gphoto2 paul$ ps -aupaul | grep PTP
502 91598 ?? 0:02.42 /System/Library/Image Capture/Devices/ -psn_0_462961
502 50334 ttys000 0:00.00 grep PTP
Paul-MBP-4:_gphoto2 paul$ kill -9 91598
Paul-MBP-4:_gphoto2 paul$ gphoto2 --capture-image

*** Error ***
PTP Invalid Transaction ID
ERROR: Could not capture.
*** Error (-1: 'Unspecified error') ***

For debugging messages, please use the --debug option.
Debugging messages may help finding a solution to your problem.
If you intend to send any error or debug messages to the gphoto
developer mailing list , please run
gphoto2 as follows:

env LANG=C gphoto2 --debug --debug-logfile=my-logfile.txt --capture-image

Please make sure there is sufficient quoting around the arguments.

DC said...

@Paul Godard: Glad to see that you're slowly making progress!

First, good catch on the 'xc'. That worked on older versions of OS X. You found a fine fix for it (or else use 'ps -e' instead).

As for the next problem, there are several possibilities:

1. It's worth double-checking, but you do have the camera plugged in to the computer via USB, right?

2. Every time you unplug the camera from the computer and plug it back in, or if you turn the camera off and on again, you'll have to 'kill' the PTP daemon again. Did you do that?

3. Make sure that your camera is pointed at something and can focus (or is in manual focus mode). If the camera can't take a photo normally, it will error out also.

4. If you've got all of the above: what model of camera do you have? Does it appear on the list of supported cameras?

Let me know, we'll keep trying!

Anonymous said...

Thanks for your help, David. I appreciate. It is so nice to have someone that helps you moving forward especially when there are many challenges on the road!
It was good to ask about the obvious... because now it works. I honestly believe that the camera was on and plugged to the Mac, but may-be it was in a mode not allowing to take the photo...
Anyway it works now.
Was does it take so much time (about 2 sec) between the moment I send the command line 'gphoto2 --capture-image' and the moment the camera shoots?
BTW, the Nikon D700 is on the list of supported camera in PTP mode.
I will do some more testing tomorow when I get my dolly cart back from Festo.
A few questions, if you know...
1/ Will the remote release port on the camera still function when gphoto2 is active and the camera connected to the Mac? I mean will an intervalometer be able to trigger the camera while gphoto is taking care of the settings for the exposure (my sophisticated intervalometer - a Festo PLC - also operates the step motor of my dolly cart for time-lapse). See
2/ Is it normal that the battery of the camera goes down quickly when the camera is linked to the Mac via USB even if there is no activity?
3/ What is the best route to go wireless for linking the camera to the Mac via USB and compatible with gPhoto?

Anonymous said...

When I run '--list-config' I get a list like :
I tried several options for '--get-config'
--get-config imgquality
--get--config /main/imgsettings/imgquality
--get--config main/imgsettings/imgquality
but it is not giving me the possible values for that parameter. It just returns all the possible options for gphoto2.

DC said...

@Paul Godard: Glad it's working! :)

For the 2 second pause -- that is one of the biggest annoyances for me. I believe that it is "initialization time", in which the software tries to get ahold of the camera and check its settings. Other programs (like Nikon's proprietary software) don't do this, so I know there must be a fix. This is also why, when using -I to take multiple exposures, you have to account for a slightly longer time between exposures than you intended. I use 34 seconds when I want to take 30 second exposures.

1/ - I have no clue about the remote release port, because my little D40x doesn't have one. As long as gphoto2 isn't actively USING the camera (changing settings, etc.), it may work. If gphoto2 IS using the camera, then I doubt it will work. You may have to work on the timing. Let me know if you find out!

2/ - That's odd, I haven't seen that myself. I can usually take about 1.5 hours worth of 30 second exposures before my battery dies, and I'm pretty sure that's from constant use. However, when it's not in use, my back screen is always lit (when connected via USB), so that may do it. Overall, I get the feeling that gphoto2 support for Nikon is much weaker than it's support for Canon.

3/ - Wireless? Like, wireless control? Not a clue, mate. Sorry!

4/ - --list-config: You're ALMOST there. Try this:

--get-config /main/imgsettings/imgquality

However, for me, that only lists the label of the setting, not its possible values.

Try this for comparison, to see what a list of settings looks like:

gphoto2 --get-config /main/capturesettings/f-number

differenxe said...

I'm also having trouble installing gphoto2. when i try the command "sudo port install gphoto2" i get the errors:

Warning: Skipping upgrade since ncurses 5.7_0 >= ncurses 5.7_0, even though installed variants "" do not match "+darwin_10". Use 'upgrade --enforce-variants' to switch to the requested variants.
Warning: Skipping upgrade since ncursesw 5.7_0 >= ncursesw 5.7_0, even though installed variants "" do not match "+darwin_10". Use 'upgrade --enforce-variants' to switch to the requested variants.
---> Computing dependencies for gphoto2
---> Configuring dbus
Error: Target org.macports.configure returned: configure failure: shell command failed
Log for dbus is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_dbus/main.log
Error: The following dependencies failed to build: libgphoto2 dbus libusb-compat popt readline
Error: Status 1 encountered during processing.
To report a bug, see

DC said...

@differenxe: Give this a try first:

sudo port selfupdate

Let that run and see what happens. It may take a while. Then try installing gphoto2 again.

differenxe said...
This comment has been removed by the author.
differenxe said...

Ok I uninstalled and then reinstalled MacPorts.

Then gphoto2 installed fine.

However, I run into problems while installing the newest libgphoto (2.4.9). after typing "sudo make" i get a lot of text, and in the end is this part:

linux.c:31:21: error: scsi/sg.h: No such file or directory
linux.c: In function ‘gp_port_usbscsi_send_scsi_cmd’:
linux.c:298: error: ‘sg_io_hdr_t’ undeclared (first use in this function)
linux.c:298: error: (Each undeclared identifier is reported only once
linux.c:298: error: for each function it appears in.)
linux.c:298: error: expected ‘;’ before ‘io_hdr’
linux.c:307: error: ‘io_hdr’ undeclared (first use in this function)
linux.c:309: error: ‘SG_DXFER_TO_DEV’ undeclared (first use in this function)
linux.c:311: error: ‘SG_DXFER_FROM_DEV’ undeclared (first use in this function)
linux.c:321: error: ‘SG_IO’ undeclared (first use in this function)
make[4]: *** [usbscsi_la-linux.lo] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

DC said...

@differenxe: A new version of libgphoto was released about a week ago which fixed some compilation issues on Mac OS X. I'd suggest downloading the newest version and giving that a try -- it sounds like that may fix your problem. Sorry to be slow!

Evan said...

Do you have a copy of darwinports for Max OSX (Snow Leopard)? When I go to download it at the site listed on your tutorial above, it tells me that it can't find the .dmg file for download. Any help would be appreciated.


DC said...

@Evan: It looks like Darwinports is overloaded. They *should* work if you try again now...

Shayna said...

I'm getting the following error on my Mac OS X when I use the "sudo make" command:

Undefined symbols:
"_jpeg_resync_to_restart", referenced from:
_jpeg_mem_src in jpeg_memsrcdest.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[3]: *** [] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Can anyone tell me how to fix this?

DC said...

@Shayna: It looks like you're missing some of the supporting software. Are you installing using Darwinports (or MacPorts)? If not, I highly recommend that, since it should install ALL necessary software.

Shayna said...

@DC I'm using MacPorts. I'm having trouble with the updating part. Any idea what I'm missing? It's supposed to be creating .o files, right? Mine is creating .ol files. Is that right?

Shayna said...

If I run the initial version from macports, it cannot detect my camera (Canon PowerShot SD770 IS- which is on the list of cameras that should work.

*** Error ***
Could not detect any camera
*** Error (-105: 'Unknown model') ***

Is there an override or something I can use?

DC said...

@Shayna: .ol files should be ok. The version from MacPorts is probably a few versions old, and the newer updates would support your camera.

If you've installed an older version already (so that all of the supporting utilities are updated), then you could download the source for the newest gphoto version from You'll have to follow the additional (update) instructions in my post to get that to work, but it may help.

Good luck!

Shayna said...

@DC yeah. thanks.

BUT that's where I'm having the first problem. When I try to update to the new gphoto version, I get this error:

Undefined symbols:
"_jpeg_resync_to_restart", referenced from:
_jpeg_mem_src in jpeg_memsrcdest.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[3]: *** [] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

DC said...

@Shayna: Ahh, ok. It looks like the jpeg errors are coming from ImageMagick, which is one of the extra utilities which *should* be installed by MacPorts. So, my recommendations are:

First, make sure macports is updated, by running 'sudo port selfupdate' and seeing what happens.

Second, if you didn't get any errors, run 'sudo port install imagemagick'

Third, if everything worked and ImageMagick installed correctly, try installing the newest gphoto again.

Shayna said...

@DC Thanks for your help so far.

Ok, so I had the most recent version, but when I installed ImageMagick, it told me I needed Java development software. So, I got that and it installed just fine.

I'm still getting the same error when I attempt to upgrade libgphoto2, BUT I may not actually need to...

Here's the situation: when I use 'gphoto2 -v', it says I have libgphoto2 2.4.10. However, when I try to update gphoto2 to 2.4.10, it gives me the following error:

configure: error: Version requirement libgphoto2 >=2.4.10 not met. Found:

So, any idea why it can't find the correct version of libgphoto2? Is there a way to redirect where it's looking?

I'm hoping this is the last thing that needs to be fixed...

Shayna said...

P.S. It looks like gphoto2 only THINKS it has libgphoto2 2.4.10, but when I look in opt/local/lib, it actually has So, I guess it's back to the problem of 'make'ing libgphoto2 2.4.10(.1)

DC said...

@Shayna: Hm, so, what is the order in which you are doing the updates? Are you updating libgphoto first, and then gphoto?

To be clear, there are both gphoto2 AND libgphoto2 (separate items) which need to be updated.

Can you give me the full output of "gphoto2 -v", starting with the "This version of gphoto2 is using..." line?

Shayna said...

I am installing libgphoto2, then gphoto2 (attempting anyway).

This version of gphoto2 is using the following software versions and options:
gphoto2 2.4.9 /usr/bin/gcc-4.2, popt(m), exif, no cdk, no aa, jpeg, readline
libgphoto2 2.4.10 gcc, ltdl, EXIF
libgphoto2_port 0.8.0 gcc, ltdl, USB, serial without locking

DC said...

@Shayna: When you 'make' libgphoto2, does the compilation and installation work correctly? Any errors? Are you sure you're downloading the newest version? (Sorry for the dumb questions, but it's worth checking!)

To be sure, here are the commands you need (within the libgphoto2 directory), in this order:

sudo ./configure --prefix=/opt/local
sudo make
sudo make install

the "--prefix" bit on the configure line is important, as is the separate "install" line. You might be compiling libgphoto2, but not actually installing it at all.

Shayna said...

@DC: libgphoto2 configures fine, but when I 'make' it, I get this error:

Undefined symbols:
"_jpeg_finish_compress", referenced from:
_jl2005bcd_decompress in jl2005bcd_decompress.o
"_jpeg_set_linear_quality", referenced from:
_jl2005bcd_decompress in jl2005bcd_decompress.o
"_jpeg_CreateDecompress", referenced from:
_jl2005bcd_decompress in jl2005bcd_decompress.o
"_jpeg_set_defaults", referenced from:
_jl2005bcd_decompress in jl2005bcd_decompress.o
"_jpeg_destroy_compress", referenced from:
_jl2005bcd_decompress in jl2005bcd_decompress.o
"_jpeg_mem_src", referenced from:
_jl2005bcd_decompress in jl2005bcd_decompress.o
"_jpeg_finish_decompress", referenced from:
_jl2005bcd_decompress in jl2005bcd_decompress.o
"_jpeg_mem_dest", referenced from:
_jl2005bcd_decompress in jl2005bcd_decompress.o
"_jpeg_CreateCompress", referenced from:
_jl2005bcd_decompress in jl2005bcd_decompress.o
"_jpeg_read_header", referenced from:
_jl2005bcd_decompress in jl2005bcd_decompress.o
"_jpeg_destroy_decompress", referenced from:
_jl2005bcd_decompress in jl2005bcd_decompress.o
"_jpeg_write_scanlines", referenced from:
_jl2005bcd_decompress in jl2005bcd_decompress.o
"_jpeg_read_raw_data", referenced from:
_jl2005bcd_decompress in jl2005bcd_decompress.o
"_jpeg_std_error", referenced from:
_jl2005bcd_decompress in jl2005bcd_decompress.o
_jl2005bcd_decompress in jl2005bcd_decompress.o
"_jpeg_start_decompress", referenced from:
_jl2005bcd_decompress in jl2005bcd_decompress.o
"_jpeg_start_compress", referenced from:
_jl2005bcd_decompress in jl2005bcd_decompress.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[3]: *** [] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

DC said...

@Shayna: still sounds like a problem with imagemagick then. So, a few more silly questions: Do you have the OS X developer tools installed? Your Java comment earlier seems to indicate that you don't have the basic tools installed. It's a big download from Apple, but it's probably worth it!

Shayna said...

@DC I have Xcode. Do I need more than that? If so, what exactly am I missing?

DC said...

@Shayna: Yes, if you have XCode installed, then you should have everything you need.

The jpeg errors make me think that ImageMagick is still the problem Try this, in a terminal:

which convert

What is the result?


convert -version

Shayna said...

@DC after which convert I get:


convert -version gets me:

Version: ImageMagick 6.6.7-1 2011-01-18 Q16
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP OpenCL

DC said...

@Shayna: Wow, tough one! Perhaps you are having some path problems -- your shell may not "know" to look in /opt/local/lib for libraries.

First, try this in a terminal:

cd /opt/local/lib
ls | grep Image

See if anything named ImageMagick shows up. If it does, try this: in a terminal, type:

echo $PATH

the result should be a lot of paths, separated by colons. Look for /opt, /opt/local, or /opt/local/lib in the list. Let me know what you find.

Shayna said...

@DC I'm tempted to just completely start over with this thing. ha.

So, it found ImageMagick-6.6.7. echo $PATH did not come up with any of the paths you mentioned. It gave me this:


DC said...

@Shayna: Yeah, I'm tempted to say "start over!" too. I'm afraid that I don't know what else to try. You could *un*install gphoto and libgphoto using macports, and then try installing the new versions on top of that.

Shayna said...

@DC Ok.. so here's my thought, maybe you can help me. I need to convince the current program to look for libgphoto2- instead of 2.4.9.

I tried replacing the zip file, but it went to the internet to download 2.4.9 because existing code tells it to do so. I tried to change the existing code (in all files that came up in a search for "libgphoto2 2.4.9"), but I don't have permission to write to them. How can I get writing permission? Isn't there something from the command line to do this?

Shayna said...

@DC alternatively, can you think of any other reason why gphoto wouldn't recognize my camera? besides an update?

DC said...

@Shayna: What zip file are you referring to, which you changed?

Also, what is your camera? (Make and model number.) Is it particularly new?

Shayna said...


that's the location of the zip file. If I remove one from there, then install- it downloads again and puts it right there. I've unzipped them and verified that the zip file has equivalent contents.

My camera is a Canon PowerShot SD770 IS. It's on the list of cameras added to an older libgphoto than 2.4.9, so it should work, right?

DC said...

@Shayna: Ahh... have you put your camera into the right mode? I'm not familiar with the 770, but you need to ensure that the camera's USB mode is PTP mode (as opposed to "MTP" mode). "PTP" mode might go by various names in the menus, but it's basically the mode which lets the camera be recognized as a camera. The other mode will make it be recognized as if it were a disk (so that you can copy images off of it).

You'll have to look through the menus and manual, but changing the USB mode might help.

Also, replacing the zip file won't work, because MacPorts can't install just *any* software... it only installs special versions of the software which are modified to work on OS X. (Basically, they try to do all of the troubleshooting ahead of time, and fix any errors before you get it.)

Shayna said...

@DC Hoorah! It's finally magically working. I'm not sure what did it. I just uninstalled and reinstalled everything a few times and now it sees my camera. But I get one of two errors:

*** Error (-53: 'Could not claim the USB device') ***
*** Error (-2: 'Bad parameters') ***

DC said...

Shayna: Yay! To fix the "cannot claim camera" problem, be sure to follow Step #3 -- killing the PTP daemon. That basically stops OS X from "claiming" the camera, so that gphoto can claim it for itself.

Shayna said...

@DC Thanks! I'm not sure what number is the PTP id though... looks like it might not know?

Shayna$ ps -e | grep PTP

75412 ?? 0:00.32 /System/Library/Image Capture/Devices/ -psn_0_315469

DC said...

@Shayna: in that example, it's 75412. Looks like your 'ps' command formats a little differently than mine.

Shayna said...

@DC ok. That's what I thought. So I did step 3, but it still won't let me capture an image. If I leave the camera in 'play' mode, it gives me: *** Error ***
Sorry, your camera does not support generic capture
ERROR: Could not capture image.
*** Error (-6: 'Unsupported operation') ***

If I put it in camera mode, it gives me the bad parameters error.

Something wrong?

Shayna said...

@DC Alright. so the other operations are working, just not capture. Hopefully I can figure it out from here on my own, but if you do have any extra hints/tips, please let me know.

Thanks so much for all of your help!!

DC said...

@Shayna: you're welcome! It's possible that your camera isn't fully supported (although, capture mode SHOULD be supported... that's odd). Try fiddling around with the exposure settings on the camera, and you may find that it starts to work. For example, on my Nikon D40, "bulb" mode isn't supported, while everything else is.

ContritePugilist said...

@Shayna It looks like I'm having the exact same problems you were having with the jpeg stuff. Did you ever figure out how you resolved it?

DC said...

@ContritePugilist: One of the key things ended up being this: be sure your camera is in "PTP" mode (the mode which lets the camera be controlled over USB), instead of "MTP" or "Mass Storage". Otherwise, I'm not entirely sure what helped Shayna! We tried a LOT. :)

Shayna said...

@ContritePugilist: Pretty much everything we did is documented above. After all that, it turned out that my camera didn't support all of the functions. You can find out what your camera supports by running

gphoto2 --summary

That will tell you if it has capture capability and such. I tried with a few different cameras. It seemed to me that more things worked with a camera that set capture mode (manual, night vision, fast motion, etc) and camera mode (picture, video, review/play) separately could do more than one that has one wheel to control both. In other words, if you can set the capture mode even when your camera is in 'play'/review mode, then you will likely have more capabilities through gphoto. This may or may not be true, but it at least seems that way from my experience.

Unknown said...

Im having problems killing the process. if i follow the directions i get the following:

new-host-2:~ jbrodie$ ps -e | grep PTP
80176 ttys000 0:00.00 grep PTP
new-host-2:~ jbrodie$ kill -9 80165
-bash: kill: (80165) - No such process

Every time i check the process ID it has changed. how do i nail it down?

DC said...


That's because the process ID is 80176, not 80165... hehe!

So you're right, the process ID constantly changes. However, the process should stay dead until you disconnect and reconnect the camera, or turn the camera off and on again. So, kill it once the camera is already connected, use the camera with gphoto, and don't disconnect until you're done. That will hopefully help.

René Vogel said...

hmm... exact the same error in my installation:

_jl2005bcd_decompress in jl2005bcd_decompress.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[3]: *** [] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

the newest Developer Tools from Apple
the newest ImageMagick
the newest MacPorts
any new ideas??

DC said...

@vogel: Was this while installing the newest gphoto and libgphoto, or during the macports installation of the old gphoto?

Also, I generally think that the macports gphoto is "good enough" now that it's up to 2.4.9 (the newest version is 2.4.10, which doesn't have any major changes). If that successfully installed, I'd probably stick with it instead.

René Vogel said...

2.4.9 works without any problems but, the cam is a d7000 :-(
the installation via ports works perfect - but i need the installation with the new cam...

DC said...

@Rene: A few questions: did you do these three commands, in this order?

sudo ./configure --prefix=/opt/local
sudo make
sudo make install

If not, try

make clean

then repeat those three. It looks like the error is a library included with libgphoto, so we *should* be able to get it to work!

René Vogel said...

yes - exactly these three comands
i repeated this (after a make clean) also three times and every-times the same error.
also tried with XCode 4 SDK :-(

is there a successful installation of 2.9.10 on a Mac?

thanks for your help

DC said...

Oh dear, something has changed! I had previously installed 2.4.10, but if you look closely, there is now "". The installation instructions call for using fink (similar to macports) to install more software. I'm trying it now, not sure what will have to happen...

René Vogel said...

any news? i tried also with 2.4.10 (not but the error is the same :-(
hope to find a solution soon...


DC said...

@Rene Vogel: I had no luck in getting it to compile. This is strange, because I got 2.4.10 to work previously. Unfortunately I don't have an answer for you right now, but I'm still working!

René Vogel said...

i have to change the cam from d7000 to d90 for this project - time is running out - but i'll check this page how often it's possible to be up-to-date :-)

DC said...

@Rene Vogel: Sorry to be slow. I discussed this problem on the gphoto user email list. The solutions were not helpful, except that others HAVE managed to get the newest gphoto and libgphoto to compile successfully on OS X. I tried their methods, but still got the same problems. :(

DC said...

Hello everyone who's still watching this -- good news!

It looks like MacPorts has update to libgphoto2! This is the newest version available anywhere, and now it can be installed with just:

sudo port install gphoto2

Give it a try... works for me, but let me know if it doesn't.

Mackenzie said...

the homebrew package manager for os.x is a lot easier to use, in my opinion, than macports or fink. And gphoto2 is available in homebrew.

Anonymous said...

See for an automated way of killing the PTPCamera process on MacOSX.

Şükrü Ozan said...

Valuable information for a new mac user like myself...

Anonymous said...

Thanks for the great info. Just picked up a refurb T2i and wanted to know the shutter count.

Came back with a "40" -- brand, spanking new apparently!!!

Andrey Valentsov said...


I heard that you managed to make some sort of script to increase exposure for day-to-night timelapse.

Can you provide some information regarding that script?

Thank you

DC said...

Lohmatij, I'll write a new post some time shortly with details. It's a bit more than can fit in a comment-- but watch the blog!

Andreas said...

I built a MacOS Framework which can be used in XCode directly.

DC said...

Andreas: Sweet! I'll add a mention of this to the article.

jarno said...

This is a really fun program however, after taking 1 picture, I keep getting a "segmentation fault". No matter what I do.
Is there a site where I can get some support for gphoto2?

Unknown said...

Initially had issues trying to run the update. I temporarily turned my firewall off and then it worked fine. Thanks.

ewster said...

Thanks for posting this. Gotta be a genuine geek to get gphoto2 rolling on the mac but the shutter count info worked for me on the 5D MkII, 5D MkIII and 1D MkIV. :)

Irandar said...

I am more or less successfully trying to get gphoto2 to control my Canon Powershot A40 with my Mac. Would it be ok if I posted some of my results and scripts here?
Regards Irving

DC said...

@irandar: Glad things are working for you! If you have working scripts, feel free to post them (and I'll take a look!). But if you want to showcase photos, it might be best to post them on flickr or your own blog -- they'll largely be lost here in the comments.

Gumper said...

Just found this article about Gphoto2 and basics of using it. VERY helpful for a Linux noob like me as far as other info on the web is concerned.

My old Canon 20D works great on it and does not need PTP mode.

Unfortunately, my new Canon 80d is not compatible. I have asked on the Source Forge forum for info but no one is aware of anything. They thought it should just be automatically working when connected.

Any one here know of any info to make it work would be appreciated.
Thanks for the article.

DC said...

Hi Gumper -- I don't see the 80D on this list of supported cameras:

Perhaps it's too new? Support could be coming in a future update.

That said, it shouldn't be *that* different-- I would expect things to work still. So, a few basics: Are you on the latest gphoto? Is the 80D in PTP mode (not mass storage)?

Gumper said...

Too new? Ya I figured since its not on the camera support list, thats why I asked on them on that forum and Marcus Meissner claimed it should still work.

I have the latest version 2.5.9-3

Oddly I cannot find PTP Mode on the 80D.
Perhaps thats the problem?

I also found this thread on Github about the issue.

So I wondered if its me doing something wrong or its an update I need to wait for.

ab1jx said...

The 80D is supported now. And for anyone looking the list is at