Sunday, March 9, 2008

Recovering photos from a damaged card

4 years ago, I visited Vietnam but I had a big problem with my digicam at that time. Just before the trip, I bought a microdrive 2GB (second hand) and changed my camera from an old Powershot A20 to Powershot S50 (only Canon compact camera to handle microdrives at that time). And I did a newbie mistake :"ok, with one 2GB card, I'll have plenty of space for the entire trip". And of course, the card died on the 4th day of my 2-week trip (and I was fortunate to travel with other people who lend me additional cards I unload quite often to CD-R in various Internet shops across Vietnam).

When I came back, I tried to access the card with my card reader but kernel was not seeing anything. But I never dumped the card, thinking "one day, I'll send it to a recovery company if it doesn't cost too much".

And today, I thought : why not try again, since I heard good opinions about PhotoRec (I quickly met its author at Solutions Linux last month). And guess what : it worked !!

I started PhotoRec in "scan the entire drive" mode and it found 159 files. Then I tried to mount the drive as a FAT partition and it also worked (maybe kernel code for vfat or for usb retry became more robust since last time I checked) and recovered 155 files.

For now, I've been able to confirm 139 files as valid (retrieved by both PhotoRec and direct mount access, with identical md5sum). I have 16 files from "mount method" which have different md5sum as their PhotoRec counterparts. According to file naming, I'm still missing 54 files but I think I have removed them during my trip.

So, I had to dig a little into Photorec recoved files ; some files contains additional padding or even start of next file on disk, after last JPEG end mark (FFD9), which is changing file md5sum. I confirmed 15 files from "mount method" had similar md5sum than PhotoRec files, truncated with help of Hexedit. The last one has only a partial recovery version from counterpart from PhotoRec recovery

Fortunately, I found interesting informations on PhotoRec website, such as file numbering being included in Canon EXIF JPEG file (Canon maker tag 0008, see here or use exiv2 and check image number field), which helped me to fill gaps in the PhotoRec recovered files.

According to file naming/numbering, 54 files are missing but I think I have removed them during my trip, when I discovered photos were bad.

In short, I've been able to recover all files from my damaged microdrive (I don't know yet if I'll dump it in the trash or keep it as a souvenir), thanks to PhotoRec. For people interested, I've uploaded those pictures to my Flickr account (I haven't sorted them, despite my recent decision to try to only upload selected photos Flickr, but I want to be sure those specific pictures are hosted in several physical locations ;), and I've tagged them with photorec tag.