Linux 通过 gphoto2 操作 Canon 450D
摆弄450D有一段时间了,每次使用 Windows 自带的数码相机向导,把照片从相机导入到笔记本,接下来用 PhotoShop 进行 PS。直到今天,心血来潮,倒腾一下,把照片直接导入到 Debian 上,以下记录了这个过程,其中所遇到的问题和解决办法相信对自己今后或别人是个帮助。
首先,安装两个软件,基于命令行(command-line)的 gphoto2 和图形界面的 gtkaw。如果你是命令行的狂热粉丝,那么后者可以不安装,不会影响到任何操作。
在安装之前,先来了解下你将要使用使用的工具:
gPhoto2 is a free, redistributable, ready to use set of digital camera software applications for Unix-like systems, written by a whole team of dedicated volunteers around the world. It supports more than 1200 cameras
gPhoto2 runs on a large range of UNIX-like operating system, including Linux, FreeBSD, NetBSD, MacOS X, etc. gPhoto is provided by major Linux distributions like Debian GNU/Linux, Ubuntu, Gentoo, Fedora, openSUSE, Mandriva, etc.
— www.gphoto.org
eniac:~# apt-get install gphoto2 gtkaw |
然后,连接好 Cannon 450D和笔记本,打开450D,执行命令,查看 gphoto2 是否识别到了450D:
xuhj@eniac:~/img/450D$ gphoto2 --auto-detect Model Port ---------------------------------------------------------- Canon EOS 450D (PTP mode) usb: Canon EOS 450D (PTP mode) usb:001,013 |
看来比较顺利,接下来查看450D都有哪些文件:
xuhj@eniac:~/img/450D$ gphoto2 -L *** Error *** An error occurred in the io-library ('Could not claim the USB device'): Could not claim interface 0 (Operation not permitted). Make sure no other program or kernel module (such as sdc2xx, stv680, spca50x) is using the device and you have read/write access to the device. *** Error (-53: 'Could not claim the USB device') *** 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 --list-files Please make sure there is sufficient quoting around the arguments. |
看样子遇到了大麻烦,还好从 gphoto2 的官网上了解到问题的原因:
You have to make sure that no such kernel module is loaded and that you have set up the permissions on your USB device correctly, such that you have (non-root) write access to the camera device.
根据官方给出的建议,执行下面的命令:
eniac:~#/usr/lib/libgphoto2/print-camera-list udev-rules version 0.98 group plugdev mode 0660 > /etc/udev/rules.d/90-libgphoto2.rules |
完了以后,再来查看文件:
xuhj@eniac:~/img/450D$ gphoto2 -L There is no file in folder '/'. There is no file in folder '/store_00020001'. There is no file in folder '/store_00020001/DCIM'. There are 5 files in folder '/store_00020001/DCIM/100CANON'. #1 IMG_3471.JPG rd 1685 KB 3088x2056 image/jpeg #2 IMG_3472.JPG rd 1598 KB 3088x2056 image/jpeg #3 IMG_3473.JPG rd 1782 KB 3088x2056 image/jpeg #4 IMG_3474.JPG rd 1624 KB 3088x2056 image/jpeg #5 IMG_3475.JPG rd 1870 KB 3088x2056 image/jpeg There is 1 file in folder '/store_00020001/MISC'. #6 AUTXFER.MRK r- 1 KB text/plain |
哈,看来办法奏效了,接下来就是拷贝需要的文件到当前目录了:
xuhj@eniac:~/img/450D$ gphoto2 -p 1-5 Downloading 'IMG_3471.JPG' from folder '/store_00020001/DCIM/100CANON'... Saving file as IMG_3471.JPG Downloading 'IMG_3472.JPG' from folder '/store_00020001/DCIM/100CANON'... Saving file as IMG_3472.JPG Downloading 'IMG_3473.JPG' from folder '/store_00020001/DCIM/100CANON'... Saving file as IMG_3473.JPG Downloading 'IMG_3474.JPG' from folder '/store_00020001/DCIM/100CANON'... Saving file as IMG_3474.JPG Downloading 'IMG_3475.JPG' from folder '/store_00020001/DCIM/100CANON'... Saving file as IMG_3475.JPG |