Search Tillamook Rage
Google Custom Search

4.03.2008

Digital Imaging In Linux

You might be interested in this post if you want to use digital cameras and/or scanners in Linux.

This procedure was developed using both Xubuntu Feisty (7.04) and Xubuntu Gutsy (7.10), but should work equally well with any version or derivative of Ubuntu or any Debian derivative - with some minor changes.

As always, be careful what you do with the advice and procedures from this site or any other, as you can do serious damage to your system if a mistake is made. Please see our disclaimer for details.

Introduction
Recently, I was thrown into the task of mind-melding Linux (specifically Xubuntu) with a newer digital camera when my dad bought a Kodak EasyShare M883. He also wanted to get an all-in-one printer so that he could print, fax, and scan. He really likes the Xubuntu Feisty system that I set up for him many months ago, and I didn't want to ruin things for him by switching it back to Windows, so I had to make things work well for him in Linux. This post is about my (mis)adventures in trying to do that. My hope is that it will give some of you a head start on using your own digital imaging equipment in Linux, and will help you avoid the same mistakes that I made.

Camera-Shy
There are several digital camera packages for Linux, and the most commonly used one is gphoto. I found that gphoto recognized my dad's M883 right off the bat, and I was able to download photos to the computer. It's interesting to note that gphoto's website didn't have the M883 on their compatibility list. That goes to show you that it doesn't hurt to try something even though you think it might not work. When you get a new camera, I would suggest just trying to plug it in first to see if Linux recognizes it as an external hard drive. If that doesn't work you can install the gphoto library manually and use it, or you can check out the next section on using Picasa. To install gphoto, open an X terminal (Applications > Accessories > Terminal) and type the following line, hitting Enter afterwards. Note that this line is installing two programs at once, gphoto2 and gtkam.

sudo apt-get install gphoto2 gtkam

The libraries and applications with the gphoto package can be used from the X terminal, but it's easiest to use it with a program like Picasa or GThumb. If you want to use gphoto by itself, you can run the program gtkam that we installed with the command above. gtkam is a graphical front end for the gphoto library which you can use to grab the photos off of your camera. I prefer using Picasa instead of gtkam, so this post will focus on that, but if you want a post on using gphoto without installing any other programs, you can ask in the comments section. We'll be happy to oblige.

Unfortunately, not every camera will work under Linux. gphoto can't cover all of the available camera models, and many companies don't put out Linux drivers for their cameras. There is still hope though, even if Linux won't recognize your particular camera. There are two basic ways to get your photos off of your camera if it has a removable memory card. The first is with a memory card reader, the kind that fits in a 3.5 or 5.25 inch bay in the front of your computer. If your motherboard supports card readers, most likely Linux will recognize it. Once you have the card reader installed you can just insert the camera's memory card and either open the card as an external drive, or use it in a program like Picasa (see below).

I have to give credit for this second technique to Boot, since I had seen these products around but never put two and two together. What you can do is buy a USB memory card adapter for your memory card type (my dad's was SD). Even when the camera isn't recognized, the adapter with the card in it will be recognized as an external flash drive. That way you can get your photos off the camera while you wait for gphoto or one of the other camera libraries to catch up. You can use it as either an external drive and just copy the files off, or you can open the card and import the photos using a program like Picasa (see below). These adapters come in several flavors, but they usually look like over-sized USB flash drives and accept memory cards (chips) like SD and XD.

Picasa
Once again, the people at Google have done the world a great favor. By teaming up with Codeweavers, Google has ported ("moved" might be a more accurate term) Picasa2 over to the Linux platform. It uses much of the original Windows code and runs it on top of the Windows emulator Wine. Not purely Linux, but an efficient way to make your app cross-platform quickly. Google currently has RPM, DEB, and BIN installers available for the i386 platform. I really like well done BIN installers, so I tried that one out. I was not disappointed. I got a nice graphical installer, and everything installed without a hitch. It's not in the Ubuntu repositories (that I know of) as of the writing of this post, so you'll have to grab one of the installers here. One side-note here is that I found documentation that said Picasa is designed for Gnome and KDE, but I didn't have any problems with it in XFCE.

I had Picasa go ahead and run the new storage detector in the background so that it would automatically detect my dad's camera, and had it put an icon on the desktop.

To import photos from your camera, attach your camera to the computer and do whatever the camera's documentation says to get the camera talking to the computer. Then run Picasa and click on the Import button shown by the red oval in Figure 1.

Figure 1

Once you are in the export screen you'll see the Select Device pull down menu shown in the red oval in Figure 2. When you click the pull down menu, you should see your camera in the list of available devices. The names can be kind of cryptic, so if in doubt, I would start at the top one and work your way down. The top entry in the pull down list is usually your camera in my experience. Once you select your camera, Picasa should start the import process. Once you're to that point, you can select photos one by one (while holding the control key) and then click the Import Selected button, or you can import all of the photos by clicking the Import All button.

Figure 2

Printers
I found an HP Officejet 6110 All-In-One for my dad at a local solid waste management district (recycling facility). See Boot's post on High Tech Dumpster Diving for ways to find good technology cheap. The printer needed a minor repair, so I got even more of a discount on it. It works great and for less than the price of the cartridges I got a complete, working, all-in-one printer. Not bad eh?

Anyway, Boot and I are pretty big fans of HP printers for Linux since we almost never have one that isn't recognized. You might have problems if you buy a bleeding edge HP printer, but one with any age on it at all should work. A lot of the printers from other manufacturers will work fine too, but they are a little more hit and miss (especially Lexmark and Xerox).

XSane...In The Membrane
XSane is a graphical program that allows you to use scanners. XSane can be integrated with Gimp for 1 step scanning for editing. More about that below. You can install XSane by opening an X terminal (Applications > Accessories > Terminal), typing

sudo apt-get install xsane

and hitting Enter. To install XSane graphically, open the Add/Remove Software dialog (Applications > System > Add/Remove...) and search for xsane. Once the XSane entry comes up, you can click the checkbox beside it and click the Apply Changes button.

Once XSane is installed, you can launch it by going to Applications > Graphics > XSane Image Scanner. You'll be presented with the set of windows in Figure 3. These windows will allow you to change things like the color balance and brightness of the document. There are many settings, and to write about all of them would take another post. I'll leave you to experiment. Make sure your scanner is turned on and plugged in to your computer, make sure your document is in the scanner, and click on the Scan button highlighted by the red oval in Figure 3.

Figure 3

XSane will scan the document and then a new window will pop up showing what was scanned. You can then do the typical File > Save As... routine to save the digitized document to the hard drive. If you go the Save As... route, make sure to set the file type using the pull down menu with the red oval around it in Figure 4, or specify the file type by typing the correct extension. So, for a JPEG file, you would type something like myimage.jpg and then click the OK button.

Figure 4

Gimp + XSane = Goodness
Most of us who run Linux (and many who use Windows) use Gimp for our photo editing. If you want to use XSane directly with Gimp, it's pretty easy to do. You can create a symbolic link for XSane in Gimp's plugins directory to make it recognized in Gimp's menu system. Before you can create this link though, you need to gather some information about the version of Gimp and where XSane is installed on your system. Open an X terminal (Applications > Accessories > Terminal) or switch back to one that you haven't closed yet, and type the following command, hitting Enter afterwards.

sudo find / -iname xsane

This search line will show you the location(s) of the xsane binary. You may see several, but look for one in either the /usr/bin directory or the /usr/local/bin directory and remember the full path. Next you can type the following line, this time hitting the Tab key afterwards.

~/.gimp-

Once you hit tab, this line will complete with the version number of Gimp that is installed on your system. Remember this version number.

Now that you have the information from the commands above, you can create the symbolic link in the Gimp plug-ins directory. For all of you who are used to Windows, a symbolic link is kind of like a shortcut. Type the following line, replacing /usr/bin/xsane with the path to xsane on your system, and the 2.4 in ~/.gimp-2.4/plug-ins with the version number of Gimp that you found.

ln -s /usr/bin/xsane ~/.gimp-2.4/plug-ins/

Make sure to hit the Enter key after you've typed in the command.

Now that is done, launch Gimp (Applications > Graphics > GIMP Image Editor). Once it launches, go to the XSane acquire menu (File > Acquire > XSane) and you should see something similar to Figure 5. Notice that I've put a red box around the XSane menu in the figure. If you've already used XSane with your scanner, you will probably see it in the list below Device dialog... and in my case it's the entry that begins with hpaio. Your scanner name will differ from mine of course. You can either click on the entry for your scanner (if it's there), or you can click on the Device dialog... entry. Each of these entries opens XSane (Figure 3), but clicking the Device dialog... entry searches for a scanner first. If after clicking one of these two entries you get a dialog box telling you that there's no device present, you need to verify that your scanner is hooked up to the computer, that's it's turned on, and that it's supported in Linux.

Figure 5

Once the XSane windows pops up (again, Figure 3) you can use it just like before, but the scanned document opens in a Gimp window so that you can start editing it immediately. I like this because it avoids the extra steps of saving the scanned image and then reopening it in Gimp. This way you also have more flexibility on what you do with the document before you save it, and which formats you can save it in.

Windows Camera Software With Wine
There is a chance that you may be able to run the Windows software that came with your camera. Wine is a Windows Emulator for Linux, and can be installed by opening an X terminal (Applications > Accessories > Terminal) and typing

sudo apt-get install wine

or you can open the software installer (Applications > Settings > Add/Remove...) and search for wine.

If you're following the X terminal route, you may be asked if it's ok to use more space on your hard drive. Just type Y and hit Enter.

Once you have wine installed, you should have a Wine item in your Applications menu. If you have the menu item, expand its menu and click on Configure Wine (Applications > Wine > Configure Wine). As you can see from Figure 6, there are a lot of options that you can experiment with when you're trying to get your Windows programs running. The one that is going to probably be the most critical to you though is the Windows pull down menu with the red box around it in Figure 6.

Figure 6

With this option set to the default of Windows 2000, my dad's Kodak software installer wouldn't even run. It complained about the version of Windows I was running. When I set it to Windows XP though, it ran fine. Once the program is installed you can open the Wine C drive (Applications > Wine > Browse C:\ Drive) and navigate to where the program was installed (probably the Program Files directory) and double click it. I can't guarantee it will work, but with some tweaking I've been able to get most things to run. Check out the Wine website for extensive information on how to configure Wine to run Windows programs.

I hope that at least gives some of you a headstart on getting your digital imaging equipment working in Linux. If you hit any snags or have any questions, post them to the comments section and we'll try to help.

Enjoy!

No comments: