COVER STORY Digital Cameras

Digital Cameras on Digital Picture Box Digital cameras continue to replace traditional cameras in today’s homes. The typical Linux approach to trans- ferring images from the camera to the hard disk is gPhoto or the kernel- based USB mass memory module. Graphical front-ends like promise enhanced usability.

BY ANDREA MÜLLER

uying films, having them devel- specifically designed for interfacing with with the VFAT filesystem, typically used oped, sorting the prints, buying digital cameras. by Windows 9x. As this filesystem does Bphoto corners and mounting the not have any permissions, the adminis- prints in albums. All of these time-con- Mounting a Camera trator can assign permissions using the suming tasks are now things of the past Some cameras, such as the Aito or Casio umask option. 0 is the most permissive for amateur photographers who have Exilim series, attach to a system as a value and grants read and write access to moved over to a from tra- SCSI hard disk, just like a USB memory any camera directory for any user. ditional wet film equipment. Those who stick is connected. You can use the An entry in /etc/fstab will allow non- have made the move, face different mount command to mount the camera privileged users to mount the camera. issues, such as finding the best software device, checking your /var/log/messages Mount options allow a more restrictive to run on their computer to transfer the file to discover the right device: approach to permissions, such as digital images from the camera to their assigning a usbusers group permissions home PC. The answer for Linux depends Feb 1 19:27:18 aries kernel:U to delete files on the camera. After creat- on the make and model of the digital SCSI device sdb: 20208 U ing the group, and defining the camera. 512-byte hdwr sectors (10 MB) mountpoint, the entry might appear as Devices that attach themslves to the Feb 1 19:27:18 aries kernel:U follows: system as though they were hard disks sda: Write Protect is off provide the easiest approach, allowing Feb 1 19:27:18 aries kernel:U /dev/sda1 /mnt/usb auto users,U users to enter a simple mount command sda: sda1 noauto,gid=333,umask=002,U to give access the device. If you have a showexec 0 0 camera that uses a special protocol to The following command, issued by root, talk to the PC, and your camera is a mounts the camera it detected as sda1: The gid entry is followed by a numerical recent model, you still stand a good ID, as stored in the /etc/group file. All chance of being to access the camera mount -t vfat /dev/sda1 U members of the group have read and using a software produced by the gPhoto /mnt/usb -o umask=0 write access to the camera. The users project [1]. This article describes both entry, in contrast to user, allows non- approaches, and introduces software in /mnt/usb. The devices are formatted privileged users to unmount the camera,

30 June 2004 www.linux-magazine.com Digital Cameras COVER STORY

despite not having mounted the camera However, this will also require you to re- ring image files to disk. Other com- themselves. compile the graphical front-end, and mands, such as outputting lists of image showexec works around a problem that gtkam, as this tool will not typically run files, led to reproducible I/O errors; GUI- stems from the fact that VFAT does not with the later version if it is linked based front ends only rarely worked. have a rights system. Users need to be against an older library. Stability improved dramatically with ver- assigned execute permissions in the Before you go to all this trouble, you sion 2.1.3. However, a camera explicitly umask, to allow them access to the should enter the gphoto2 --list-cameras mentioned in the list of supported directory structure. One side effect is that command to find out which devices are devices will be better supported than a normal files are tagged as being exe- supported by the version supplied with generic USB PTP Class Camera. This fea- cutable. Some Linux programs, such as your distribution. If you draw a blank for ture is still in the test phase. older versions of the Rox file manager, your model, you can surf to [3] to check refuse to display a preview for exe- the compatibility list for the current Permissions cutable images. You can use showexec to gphoto2 version. If your camera is supported, you still work around this, as it emulates Win- More recently, gPhoto 2 has improved have to deal with the problem of per- dows behavior. Files with the suffixes support for new models. Many of today’s missions, unless your distributor has .exe, .bat, and .com are tagged as exe- cameras use the Picture Transfer Pro- taken care to allow users other than root cutable, but no others (see Figure 1). The tocol (PTP) [4], which ensures a simple to access the camera. USB cameras are fstab entry allows normal users to mount file transfer between PTP devices. This detected by the system as entries below the camera in /mnt/usb using mount removes the need for special drivers, and the mountpoint /proc/bus/usb. This is /dev/sda1. allows any computer to exchange data where the USB device filesystem is Suse Linux users can avoid this man- with any other PTP-aware devices with- located; the kernel generates the filesys- ual work. The hotplug daemon out installing additional software. tem generically in a similar way to the automatically creates an appropriate These devices do not need to be /proc pseudo-filesystem [5]. Permission fstab entry, as soon as a USB mass mem- limited to cameras and computers; changes are lost each time you reboot. ory device is attached. exchanging data with cellphones or There are two ways to provide users You can use more or less any file man- printers is just as easy. PTP-cameras run access to the camera: ager to transfer the image files from the “out of the box” on Windows XP and • Changing the mount options for the camera device to your hard disk. If you MacOS X. USB filesystem; prefer a specialist program, try Digikam • Dynamically setting permissions using [2]. This is the only camera front-end Enhanced Support thanks to the hotplug daemon. that works with gPhoto 2 and also sup- the PTP Standard The first approach is the simpler of the ports USB mass memory devices. Although the standard was published two. The following /etc/fstab entry back in 2000, very few manufacturers The gPhoto Project were prepared to adopt it originally – none /proc/bus/usb usbfs U gPhoto 2, which reached version 2.1.4 in Kodak and Sony were among the pio- devmode=0664,devgid=333 0 0 January 2004, consists of two compo- neers. Fortunately, other manufacturers nents: the libgphoto2 library, which have begun to appreciate the advan- mounts in /proc/bus/usb with read and supports more than 400 camera types, tages, such as cost savings, as they no write permissions for user and groups and the gphoto2 command-line program, longer need to produce their own dri- with the ID 333 (this is usbusers on our which allows users to access supported vers. system). Users who are not members of cameras. gPhoto 2 introduced PTP camera sup- this group have read access only. The project has its roots in port in June 2002. It was fairly spartan at These mount options are valid for any gphoto0.4.x. The older version had an first, and just about capable of transfer- USB device and not just for the camera. integrated graphical front-end and a monolithic architecture. gphoto2 has a modular structure, and was completely re-written by its developers. The first stable version was released for down- loading in February 2002. New versions of the software are released every few months, with beta versions and pre- releases to stop the gap between stable releases, and allow users to test new cameras. As the versions included by distri- butions tend to lag behind the current state of development, users with new models will need to compile the sources. Figure 1:The mount option “showexec” copies Windows file permissions under Linux.

www.linux-magazine.com June 2004 31 COVER STORY Digital Cameras

The hotplug daemon provides a Intuitive Filenames more elegant approach to solving The program can do more than this problem. It monitors the sys- this. Digital cameras assign tem’s USB ports, and recognizes fairly non-intuitive filenames to any attached USB devices by images, but gphoto2 can change their IDs, which are stored in the names when downloading files below /etc/hotplug. De- Figure 2: gPhoto 2 recognizes newly attached cameras automatically files. To do so, specify the --file- pending on your distribution, the by the USB connection. name parameter, followed by a daemon parses either the name. --filename accepts typical /etc/hotplug/usb.usermap or /etc/hotplug/ start with usbcam, and then add the cur- date format strings, such as %y, %m, usb/usbcam.usermap file for the camera. rent camera ID to the end of the file: and %d for year, month, and day. Also, %n specifies a number, %C specifies a Scripting /usr/local/lib/libgphoto2/U file suffix, and finally %f specifies a file- When the daemon connects to a device, print-usb-usermap >> U name without a suffix. gphoto2 -P it calls the /etc/hotplug/usb/usbcam /etc/hotplug/usb.usermap --filename birthday_john_%n.%C down- script, which sets permissions for the loads the photos from the camera and attached camera. libgphoto2 provides Setting up the camera like this allows constructs a filename using the string four sample scripts. If you built the pro- normal users access. A graphical front- birthday_john_, the image number, a gram yourself, you will find them in the end is not necessarily required. The dot, and the file suffix. source code directory below packaging/ gPhoto 2 command-line tool provides a The parameters -T and -t number(s) linux-hotplug. Most distributions store wide range of functions. The following download any or a selection of thumb- them below /usr/share/doc/libgphoto2- syntax: nails for your photo collection. If you versionnumber. have a camera that can store audio clips The four supplied sample scripts con- gphoto2 --auto-detect in addition to images, you can specify -- sist of: usbcam.group, where the get-audio-data number(s) or --get-all- administrator enters the group to be shows our camera as detected by the audio-data to access these files. To make assigned the correct permissions, usb- program (see Figure 2). room for new images, enter --delete-files cam.user, which expects the name of the number(s) and --delete-all-files. user to be granted permissions, usb- Command-Line Access The features that gPhoto 2 offers de- cam.x11-app, which will automatically to the Camera pend to some extent on the attached ca- launch a gPhoto front-end, and usbcam. Just a few flags are required for basic mera. gphoto2 -a will output the features console. access. -l lists the directories, -L adds the of the attached device (see Figure 4). The script requires PAM [6], which is filenames. Users can refer to the serial Some cameras allow you to upload installed by default on Red Hat or Man- numbers in this output (see Figure 3 image files. The -m flag, followed by a drake Linux. It assigns all permissions below) using the -p number(n) syntax, name, creates a directory on the camera, for the camera to the user logged on to to filter specific files. -P refers to all the and gphoto2 -u filename uploads files. the console. If you build your own images found in the current working The output from gphoto2 -a is not gPhoto version, you will need to update directory. entirely reliable. Although the driver for usbcam.usermap using the following If you only want to transfer specific our lab camera is not supposed to sup- command: image files to the hard disk, you can port capture according to the program, it specify these files as gphoto2 -p 2,4,5 to is possible to remotely control the cam- /usr/local/lib/libgphoto2/U download images 2, 4, and 5, or specify era, and gphoto2 --capture-image will print-usb-usermap > U a range, as in gphoto2 -p 2-4. It is quite capture an image. Unfortunately. the -- /etc/hotplug/usb/usbcam.usermap simple to exclude files from a range. For capture-sound option led to reproducible example, gphoto -p 2-6,4 downloads the I/O errors in our Linux labs. If your distribution parses usb.usermap, images 2, 3, 5, and 6, but not file num- The -- parameter allows users you will need to delete any lines that ber 4. to navigate the camera directories, just

Figure 4:The -a flag lists the camera’s capabilities, telling you if the camera Figure 3: gPhoto 2 displaying a list of the images on the camera. supports thumbnails for example.

32 June 2004 www.linux-magazine.com Digital Cameras COVER STORY

like a local filesystem. Users The oldest contender is can enter gphoto2 --shell to gtkam [7], which is a fairly pop up the program’s internal staid affair (see Figure 5) that command-line. If you have provides only basic function- ever used a text-based FTP ality. Selecting Camera | Add client, you should have no Camera | Detect tells the pro- trouble finding your way gram to access gPhoto 2’s around. auto-recognition function. You can use a file manager Additional Functions style tree view to navigate the help in the gPhoto2 shell lists directory structure on a sup- the available commands, help ported camera. GTKam commandname displays the displays images in the right- syntax for individual com- Figure 5: Clear-cut and functional: the GTKam GUI. hand panel. The thumbnail mands. ls lists the files. cd view provides an initial over- changes to another camera directory. image file, but refused to work in our view. The File menu allows you to delete file deletes a file. get file starts lab. q, quit, or exit quits the program’s download all or selected images, and downloading a photo to the current command line. delete any images that you have success- working directory, and get-thumbnail fully transferred to your hard disk. does the same thing with the thumbnail Graphical Front-Ends digikam provides far more user conve- for the current image. If you open the If you are unhappy with the command nience. Instead of deserting the user gPhoto shell in a directory where you do line, you can try one of the graphical after downloading the image files, the not have write privileges, you can type front-ends for gphoto. There are several tool also manages images on the hard lcd directory to change to another local currently competing for the position disk. Images are organized in albums, directory. The show-exif file command is of the amateur photographer’s best which are in fact simple directories. The designed to display the meta-data for an friend. program will display the albums rather

EASY TO BUY • EASY TO SET UP • EASY TO SEE

one elephant... Be a host with the most for the least using our world class web hosting services. From just £30 a year. two elephant... Do the business brilliantly with our Count on us for EasyVserver. Launching your own web busi- ness has never been so affordable. Choose from 4, 8 or 16 Gigabyte options. There’s no set up fee and web host manager makes managing big web benefits multiple domains and email accounts easy.

three elephant... Make a name for yourself with an unforgettable e-mail address from the UK’s favourite domain name registrar. Why be boring? Give hotmail the cold shoulder. Give yahoo the old heave-ho. And be unique, four elephant... such as [email protected], [email protected], [email protected], [email protected]. Access email anytime, anyplace, anywhere five elephant... with Easypost. That’s our brilliant web mail package Log on in seconds and refresh your From only £3.99 a year. that enables you to pick up and send email using your domain name, making you look more professional. It’s business image the easy way. also anti-spam and anti-virus to ensure you don’t pick up anything nasty along the way.

Log on now and find out why 1/2 million customers already put us first. Register at www.easyspace.com

Established in 1997 with over 1/2 million customers. Accredited ICANN registrar & nominet member. Prices exclude VAT. COVER STORY Digital Cameras

than providing an overall view of the • Mail function with options for chang- The program is really an image manage- complete filesystem tree. Thumbnails are ing the size and compression rate of ment tool that offers camera access as an displayed in the right-hand panel (see the files. Works with KMail, , add-on. The tool lacks a separate option Figure 6). You can drag & drop an image and Mozilla. for deleting images from the camera. The to copy or move it to another album in With regards to managing and archiving Album | Import | Camera dialog does the tree view. digital images, Digikam has developed provide a simple workaround, however. features that cater to user’s every need. When you launch this item, FLPhoto Digikam, the Shooting Star flphoto [8] takes a different approach. autodetects the camera, and displays Digikam demonstrates an open preview thumbnails of the approach when setting up a images in the transfer window camera. Besides models sup- (see Figure 8). ported by gPhoto 2, it also The image management fea- provides access to USB mass tures themselves are very storage devices. You can select advanced. The program works USB Mass Storage and enter a with albums, which are actually mountpoint (see Figure 7) to set text files containing the names up this type of device. Selecting of the images in the album. If Camera | Connect mounts the you select Image | Remove to device in the file system. delete an image from an album, Besides functions for down- this does not delete the image loading and deleting images, file physically from your disk. Digikam also has an upload The preview bar at the bottom function. To view images at full of the window is more practical scale, you can optionally open than the typical tree view, as it your images in an external leaves more room for images on viewer, rather than in the inter- Figure 6:Tree view, camera view, and preview in Digikam. the desktop (see Figure 9). nal viewer. KDE programs such If you prefer to use the same as kuickshow and kview are program for all of your file oper- examples of external viewers. A ations, you might prefer to stick slideshow function, which with the KDE file manager, optionally supports filename Konqueror, when transferring labels, rounds off the program. images from you camera to disk. The new version 0.6.0 may Thanks to the camera Kioslave, already have been released by the KDE file manager tool can the time this article appears. use the libgphoto2 library to Version 0.6.0 will again have access any supported digital added functionality. Digikam cameras, just as though they uses a plug-in architecture in the were a locally attached filesys- new version, allowing develop- tem. Typing camera:/ in the ers to extend the program’s address line as the URL launches functionality. Release Candi- the auto-detect process, and tells dates 1 and 2 already had a Konqueror to display the cam- feature-rich plug-in collection era’s root directory. that provide the following exten- sions among others: Specialists for Exif • Slideshow with effects; Figure 7: Digikam also supports cameras that the system detects as Information • MPEG encoder which can use USB mass storage devices. Images from some digital cam- the mjpeg-Tools and Image- eras include so-called Exif magick, to create videos for (Exchangeable Image File For- VCDs, SVCDs, or DVDs; mat) [9] headers, which store • HTML Gallery, an extension information such as a time- of the Konqueror Gallery plug- stamp, the focal distance, the ins; flash mode, and the camera • Comment editor; type. Users who want to retain • Photoprint Wizard to arrange this meta-information while pro- multiple images on a single cessing images cannot use page; traditional image manipulation • CD archival (needs K3b); Figure 8: Importing images from a digital camera in FLPhoto. tools to do so, as the meta-infor-

34 June 2004 www.linux-magazine.com Digital Cameras COVER STORY

mation is lost when you save the camera advantage of creating loss-free jpeg files. INFO image on your hard disk. If you use convert, storing a file will re- The next version of Gimp looks set to compress the image and lose image data. [1] gphoto2:http://www.gphoto.org/ provide an answer to this dilemma, as it JPegtran is part of libjpeg, and should be [2] Digikam:http://digikam.sourceforge.net/ can keep the Exif information. In the available with most distributions. [3] List of gPhoto2 compatible cameras: meantime, you should opt for a com- The most straightforward solution for http://www.gphoto.org/proj/libgphoto2/ mand-line tool called jhead [10]. jhead viewing Exif headers at present is a GTK support.php parses the Exif header, stores it, and then program called gexif, which is available [4] with PTP support: sends the image to another program as a download from the libexif project http://ptp.sourceforge.net where it can be edited. When editing is homepage [11]. It uses tabs to display [5] USB device filesystem:http://www. complete, jhead reinstates the Exif the individual fields, and even shows linux-usb.org/USB-guide/x173.html header. The following syntax would do explanations for some types of content [6] PAM:http://www.kernel.org/pub/linux/ just that: (see Figure 10). If you are not in a hurry, libs/pam/ the next version of Digikam, 0.6, will [7] Gtkam: jhead -cmd "jpegtran -rot 270 U have the same feature. http://www.gphoto.org/proj/gtkam/ &i > &o" portrait_photo.jpg exiftags [12] is useful for displaying [8] flphoto: Exif information in the command line. It http://www.easysw.com/~mike/flphoto/ jpegtran rotates the image 90 degrees to separates the output into camera and [9] Exif:http://www.exif.org/ the left (-rot 90 will rotate through the image specific parts. The same package [10]jhead:http://www.sentex.net/ same angle, but to the right). This is also includes exifcom, which you can use ~mwandel/jhead/ something that amateur photographers to fill the UserComment field of the Exif [11] gexif:http://sourceforge.net/projects/ need quite often, if they take snapshots header – this assumes that the camera libexif/ with camera in an upright position. actually sets this field. Calling the tool [12] exiftags:http://johnst.org/sw/exiftags/ jhead &i with the name of the original without any flags will display a com- file. &o refers to a temporary file where ment, if available. the results will be stored. jhead inserts not looked at the digital camera world the Exif header into this file, and exifcom -w "my U for quite a while, as there has been some replaces the original image with the comment" U tremendous progress in this area over rotated image. As the program automati- imagefile.jpg the past few months. cally assigns the right filename, you can The KDE project, Digikam, is a con- use wildcards, like *.jpg, to process mul- will set or overwrite the comment. If you vincing example of this – a powerful, tiple images in a single batch. want to prevent exifcom from prompting and comfortable package, that makes before actually overwriting, simply add image processing on Linux a real plea- JPegtran Better than the -f flag. sure. Even if you are out of luck, and Imagemagick Digikam does not support your camera, Compared to convert from the Where There’s a Will... you can still resort to a USB-based card Imagemagick package, the JPegtran pro- Some people still maintain that Linux reader, which is guaranteed to be capa- gram used in our examples has the and multimedia don’t see eye to eye. ble of transferring your snapshots to They obviously have your hard disk. ■

Figure 10: Gexif displays the full range of Exif information, from the camera set- Figure 9: Preview window and image view in FLPhoto. tings to thumbnails.

www.linux-magazine.com June 2004 35