How to download photos and movies from the Palm Centro to a Linux desktop

Posted by Tom Moertel Fri, 02 Nov 2007 19:32:00 GMT

I recently got a Palm Centro smartphone, and so far I love it. Like most modern cell phones, it has a built-in camera and takes decent snapshots and even records short movies. It’s great for spur-of-the-moment shots when I don’t have my real camera. The trick – and there’s always a trick when it comes to cell phones – is getting the photos off the camera and onto my computer.

To get at my pictures, Sprint would prefer that I sign up for their ludicrously expensive “PictureMail” service. Leave it to weasely telecom execs to come up with another way to squeeze money from teenagers: charge them $5 each month for the “privilege” of sharing their pictures with friends. This fee, of course, is in addition to the fee for “unlimited” mobile Internet use. I guess picture bits are somehow more expensive to move over the air than other kinds of bits.

In any case, my next goal after getting my Centro to hotsync with my Linux workstation was to figure out how to download my photos and movies.

After a bit of hacking, I figured out that the Centro stores images in a typical digital-camera-image (DCIM) hierarchy. For example, I have a 4-GB microSD card installed in my Centro, and I store my photos in the “Palm” album on it. This album ends up stored in the /DCIM/Palm directory on the card.

Using the pilot-xfer program from the pilot-link project, I was able to find the directory and its contents. The trick was to use the sparsely documented –D flag to work with the Centro’s virtual filesystem. Here, for example, is how I list the contents of the Palm album:

$ pilot-xfer -p usb: -D /DCIM/Palm -l

   Listening for incoming connection on usb:... connected!

   Directory of /DCIM/Palm...
        652 Fri Nov  2 08:17:06 2007  Album.db
     292053 Fri Nov  2 09:04:20 2007  Photo_110207_001.jpg
      78493 Fri Nov  2 08:17:06 2007  Video_110207_001.3g2
         20 Wed Oct 31 12:09:20 2007  Thumbnail.db

   Thank you for using pilot-link.

Here, you can see that I have one photo and one movie in the album. (Movies are stored in .3g2 files that contain MPEG4 video.)

To download the files, I again turned to pilot-xfer, this time using the –f (fetch) flag to fetch a list of files. Here, for example, I’ll fetch the image from the listing above:

$ pilot-xfer -p usb: -D /DCIM/Palm -f Photo_110207_001.jpg

   Listening for incoming connection on usb:... connected!

   Fetching '/DCIM/Palm' ... (292053 bytes)   285 KiB total.

   Thank you for using pilot-link.

So that’s the process. It’s kind of clunky, so I wrote a small Python program to automate it. (I’m learning Python. If you’re a Pythonista, please consider critiquing my code. I would be especially thankful if you could point out any helpful idioms that I may have overlooked.)

Here’s how to use the program:

$ get-pilot-photos.py --help
Usage: get-pilot-photos.py [options]

Options:
  -h, --help            show this help message and exit
  -s SRCDIR, --srcdir=SRCDIR
                        VFS dir on Palm device from which to fetch images
  -d DESTDIR, --destdir=DESTDIR
                        Where to save the images on your computer

Both the —srcdir and —dstdir options are optional. If you omit the first, the program will download photos and movies from the /DCIM/Palm album. If you omit the second, the program will save the downloads to a new, timestamped directory within your home directory.

That’s it. The code is below.

#!/usr/bin/env python

# get-pilot-photos.py -
# Download photos and movies from my Palm Centro via pilot-link
#
# Tom Moertel <tom@moertel.com>
# 2007-11-01
#
# Copyright 2007 Thomas G. Moertel
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# See <http://www.gnu.org/licenses/> for more.

import os
import optparse
import re
import subprocess
import time

PILOT_XFER = 'pilot-xfer'
DEFAULT_PALM_IMAGE_DIR = '/DCIM/Palm'

class PhotoImporter(object):

    def __init__(self, src_dir, dest_dir=None):
        self.src_dir = src_dir
        self.dest_dir = dest_dir or self.get_image_dir()

    def run(self):
        print 'Finding images in %s on your Palm device.' % self.src_dir
        print 'Begin hotsync now...'
        images = self.get_image_list()
        if len(images) == 0:
            print 'No images were found.  Done.'
            return
        print 'Found %s images' % len(images)
        print 'Waiting for hotsync to complete...'
        time.sleep(10) # give 1st hotsync time to complete
        print 'Begin another hotsync now...'
        self.fetch_images(images)
        print 'Done.  The images were fetched to the following directory:'
        print self.dest_dir

    def get_image_list(self):
        cmdline = [PILOT_XFER, '-p',  'usb:', '-D', self.src_dir, '-l']
        proc = subprocess.Popen(cmdline, stdout=subprocess.PIPE)
        listing = proc.stdout.read()
        proc.wait()
        return re.findall(r'\b\S+\.(?:jpg|3g2)\b', listing)

    def fetch_images(self, images):
        cmdline = [PILOT_XFER, '-p',  'usb:', '-D', self.src_dir, '-f'] + images
        subprocess.Popen(cmdline, cwd=self.dest_dir).wait()

    def get_image_dir(self):
        root = os.getenv('HOME') or tempfile.mkdtemp()
        now = time.strftime("%Y-%m-%d--%H.%M.%S", time.localtime())
        dir = os.path.join(root, 'images', 'unsorted-pix', now)
        os.makedirs(dir, mode=0771)
        return dir

def main():
    p = optparse.OptionParser()
    p.add_option('--srcdir', '-s', default=DEFAULT_PALM_IMAGE_DIR,
                 help='VFS dir on Palm device from which to fetch images')
    p.add_option('--destdir', '-d',
                 help='Where to save the images on your computer')
    opts, args = p.parse_args()
    PhotoImporter(opts.srcdir, opts.destdir).run()

if __name__ == '__main__':
    main()

Posted in
Tags , , , , , ,
15 comments
no trackbacks
Reddit Delicious

Comments

  1. brmiller said 47 days later:

    Any idea where Palm stores the camera files in its internal memory if you don’t have an SD card? I haven’t located them yet.

  2. kloro said 57 days later:

    good post, tom.

    pilot-xfer was a hassle for me until i discovered that you have to start the hotsync on the Centro (Press The Button) first, then fire pilot-xfer. This is known as The Workaround at the kpilot site.

  3. Ben said 72 days later:

    OR you could save alot of time and use a card reader and open the card with konqueror or similar application. I find this much simpler.

  4. Tom Moertel said 73 days later:

    Ben, I suspect you don’t have a Centro but some other Treo because taking the memory card out of a Centro is not convenient. And I’m not the only person who thinks so:

    The back (battery) cover is hard hard to remove, and a bit stiff to get back on. The microSD card door is on the phone’s left side and looks tantalizingly accessible, but alas it’s not. The manual suggests removing the back cover before opening the microSD card slot (indeed, it’s not easy to open the plastic door unless you’ve got a long fingernail). Though the manual doesn’t suggest removing the back cover to eject a card, we found the card hung up on the battery cover’s edge, so we had to remove the cover to get the card out. (Source: Mobile Tech Review: Palm Centro)

    Trust me, you would not be saving time by trying to use a card reader with the Centro.

    Cheers,
    Tom

  5. brmiller said 75 days later:

    Agree with Tom. I tried removing the microSD card to short-cut a since-solved issue with my USB bus, and it was NOT anything you would want to do. Thanks for the python, Tom—it rocks, and got me out of jam when I needed to use my Centro to capture a brainstorm on a white board here at the office. Had to borrow a coworker’s Treo cable, but only way to get that “data” off the whiteboard short of re-copying it.

  6. medazz said 75 days later:

    how? what? How? really i cant download my videos from the card to my pc.. is thr a program to download to my pc to view or save the videos.. i can downlaod pictures just fine by removing the card .. but i cant view my videos….. help

  7. JDS said 130 days later:

    So, I have a Centro also. But no MicroSD card. All of the solutions that I have seen for getting pics off the Centro assume one has an SD card installed.

    How can I get my pics off with no SD card installed??

    Argh!

    Thanks, if anyone has a Clue™ for me.

  8. Tony said 153 days later:

    My wife has a Centro and I have a Motorola Q9c. I can cheat – all we have to do is send pics/videos, etc. via Bluetooth to my Q9c (which has Windows Mobile 6), and then I can click and drag from my sync-ed Q9c to my PC’s hard drive. It’s nice.

  9. Dan Bodoh said 181 days later:

    Without an SD Card, you need to get the FileZ palm app, and select “Show Hidden Volumes” in the prefs.

    Then, the ”/BUILTIN” card will be visible to pilot-xfer, and you can transfer photos from ”/BUILTIN/DCIM/Palm” (ore replace “Palm” with any other album name).

    For more info, see http://lists.pilot-link.org/pipermail/pilot-link-devel/2008-April/001681.html

    I’ve just finished writing a pilot-foto-centro that will work without the need for FileZ, and transfer photos from both the internal memory and the SD card. I’ve sent it to the pilot-link maintainer for inclusion into pilot-link. He will soon post it on pilot-link.org for testing.

    (email dan.bodoh at the public mail host run by google)

  10. Dan Bodoh said 192 days later:

    I’ve just built a plugin for JPilot that will download pictures, photos, and videos from the Palm Centro. It will probably also work for the Treo 680, Treo 700p, and Treo 755p, but it hasn’t yet been tested on those palms.

    It’s available in source code form at http://sourceforge.net/projects/picsnvideos/

  11. Matt said 347 days later:

    Can pilot-xfer put files back onto the Centro, or is it for downloading only?

  12. ISA said 366 days later:

    This is awesome, just what I needed. I just got a Centro and was looking for an easy way to download my pictures and video. I do in over bluetooth using the setup described at http://www.newt.com/debian/treo650.html

  13. brittany said 428 days later:

    how do u get the pics off ur palm and onto the computer ???

  14. hubiedo said 551 days later:

    it almost works. i think i understand it ok and it is trying to get the pics but can’t find the dir on my centro. any help would be appreciated

    Fetching ‘Photo_example_010309_001.jpg’... VFS path ’/DCIM/Palm/’ does not exist.

    ERROR: pi_file_retrieve_VFS failed.
  15. Diego Leon said 671 days later:

    Good script, I’m testing it under Ubuntu 9.04 with my Centro, unfortunately it didn’t work at first glance, but I’m watching some solutions like the one kioro typed. Keep on =D

Trackbacks

Use the following link to trackback from your own site:
http://tea.moertel.com/articles/trackback/616

(leave url/email »)

   Comment Markup Help Preview comment