Friday, 30 November 2007

How to copy Picasa Albums from Windows to Linux installation.

Since long ago Picasa for Windows had a nice feature called Album, which allowed organizing photos logically, rather than chronologically. Thanks to Google developers this feature is now available in Picasa Version 2.7.0 Build 37.3607 for Linux, and I started thinking about recovery my old missed albums, I had created years ago. Below are the steps I made to achieve this goal.

Disclaimer: Picasa is designed to prevent any manual changes in its internal files. Although it should not damage your data and picture files, I would suggest to backup the whole ~/.picasa folder with its sub-folders before you started.

It's assumed that:
1. you have both Picasa for Windows and Linux installed;
2. all your old photos, included in the albums, are presented in Picasa for Linux (they can be moved to Linux partition, but the folder structure should remain the same in general);
3. the goal is to copy Picasa Albums from Windows to Linux without re-creating them manually;
4. we work in Linux and have access to Windows partition with old Picasa files.
5. you know how to use Picasa and other tools involved, so I tell you what to do rather than what key to press.

Abstract

Picasa keeps information about albums in separate files located
in Windows:
[windows_drive]\Documents and Settings\[user_name]\Local Settings\Application Data\Google\Picasa2Albums\25a8e096c46096317ee356c5246889b3

in Linux:
~/.picasa/drive_c/Documents and Settings/[user_name]/Local Settings/Application Data/Google/Picasa2Albums/75adfd2e119b03b77391bf21408baf92

where
[windows_drive] is where Windows was installed, usually C:

[user_name] is user name

~ - is your home folder

25a8e096c46096317ee356c5246889b3 and 75adfd2e119b03b77391bf21408baf92 are folder names, generated by Picasa (on my computer); they will differ on your machine, I will call them [album_folder_name].

Each album is a single XML file, called like 8c5a839b4c1b71cfb65d100652642063.pal, I will call it [album_file.pal].

Next to Picasa2Albums is another folder Picasa2 with lots of sub-folders and files, do not touch them.

I did everything using default Gnome GUI tools, like Nautilus and GEdit, without using terminal and root access.

Some information used in the explanation below was found at:
http://forensicir.blogspot.com/2007/07/picasa.html


Steps

1. Open you favourite file manager (Nautilus) and go to
[windows_drive]/Documents and Settings/[user_name]/Local Settings/Application Data/Google/Picasa2Albums/[album_folder_name]
(I have changed backslashes to slashes as we work in Linux)

2. Select all [album_files.pal] and make Copy (Ctrl+C, for example)

3. Go to /tmp and create a new folder, called, for example, PicasaAlbums, then copy your files into that folder (Ctrl+V).

4. Start Picasa for Linux and create a dummy album, which includes at least one photo, same as in the old album, you are going to move. We need this step, because the location of the same file differs between Windows and Linux, and we have to find this difference.
If you moved your photos, included in the albums, so their relative locations have also changed, you have to include more than one picture from different locations to your dummy album.

5. Close Picasa.

6. Go to
~/.picasa/drive_c/Documents and Settings/[user_name]/Local Settings/Application Data/Google/Picasa2Albums/[album_folder_name]
and double click on the [album_file.pal] you have just created. This should open the file in your default text editor (GEdit in my case).

7. Go to
/tmp/PicasaAlbums
and double click on the [album_file.pal], which should contain the same pictures. It will be open in the text editor as well.

If I created a dummy album with two files in it, it would look like this in Linux:
(I have changed angle brackets to square brackets to prevent interference with HTML)

[picasa2album]
[dbid]75adfd2e119b03b77391bf21408baf92[/dbid]
[albumid]91339fd27a046527764eab636a88273d[/albumid]
[property name="token" type="string" value="]album:91339fd27a046527764eab636a88273d"]
[property name="unread" type="flag" value="0"]
[property name="description" type="string" value=""]
[property name="uid" type="string" value="91339fd27a046527764eab636a88273d"]
[property name="location" type="string" value=""]
[property name="name" type="string" value="Dummy"]
[property name="date" type="real64" value="38997.427211"]
[property name="category" type="num" value="0"]
[files]
[filename]$My Documents\PicasaDocuments\Photography\10-October-2006\07102006\P1020492.JPG[/filename]
[filename]$My Documents\PicasaDocuments\Photography\10-October-2006\07102006\P1020466.JPG[/filename]
[/files]
[/picasa2album]

And the beginning of one of my old album with the same files, as it was in Windows:

[picasa2album]
[dbid]25a8e096c46096317ee356c5246889b3[/dbid]
[albumid]55273da2ae671b7ad3fa26365dc9f5eb[/albumid]
[property name="victorrull_lh" type="num64" value="1949171729"]
[property name="unread" type="flag" value="0"]
[property name="uid" type="string" value="55273da2ae671b7ad3fa26365dc9f5eb"]
[property name="token" type="string" value="]album:55273da2ae671b7ad3fa26365dc9f5eb"]
[property name="name" type="string" value="Horse Riding"]
[property name="location" type="string" value="Helensville, Muriwai Beach"]
[property name="description" type="string" value="Horse riding and Muriwai Beach"]
[property name="date" type="real64" value="38997.427211"]
[property name="category" type="num" value="0"]
[files]
[filename][C]\Data\Photography\Panasonic Lumix DMC-FZ5\10-October-2006\07102006\P1020492.JPG[/filename]
[filename][C]\Data\Photography\Panasonic Lumix DMC-FZ5\10-October-2006\07102006\P1020466.JPG[/filename]
.....

I moved these two files, after I had abandoned Picasa for Windows, but now we can find out the difference:
[C]\Data\Photography\Panasonic Lumix DMC-FZ5\10-October-2006\07102006\P1020492.JPG
$My Documents\PicasaDocuments\Photography\10-October-2006\
07102006\P1020492.JPG

8. Switch to the file in /tmp/PicasaAlbums, and call Replace dialogue. Fill in the following fields:
Search For: [C]\Data\Photography\Panasonic Lumix DMC-FZ5
Replace With: $My Documents\PicasaDocuments\Photography
(change the above samples to your real models)
and click Replace All.

9. Make sure everything has changed properly. Save the file. Repeat two last steps, if you need more changes.

10. Copy the SINGLE [album_file.pal] you have just edited from /tmp/PicasaAlbums to

~/.picasa/drive_c/Documents and Settings/[user_name]/Local Settings/Application Data/Google/Picasa2Albums/[album_folder_name]

Important Notice: As I have already mentioned Picasa prevents modification of its internal files. The folder Picasa2 contains a lot of binary files, which keep information about existing albums, including their Hash-sums. But there is a weakness in this protection - if one adds a single album file to the folder, Picasa will accept it. If one adds two or more files at once, or tries to edit existing album file, Picasa will not allow this. Usually it just removes those files, but I am afraid there can be more serious consequences. Also do not try to manipulate with these files while Picasa is running, I neither did it myself nor want you were the first victim of this.

11. Launch Picasa and make sure the new album has appeared in the Albums section.

12. Close Picasa and repeat the steps 7...11 for other album files.

That's all. This worked for me (Picasa Version 2.7.0 Build 37.3607, 0 for Linux) and I hope this will work for you.

5 comments:

Jigar Shah said...

Ok...so one album file at a time in Picasa2Albums ?
I tries same trick last month and it worked. But there is an issue. might be with picasa4linux itself. If my drive is disconnected and i open picasa4linux, It deletes all albums. Secondly if i try to copy all album files then it does not detect them.

Unknown said...

Sorry, i missed your comment.
I think you are right. it was reported in the Picasa blog, that if either photos or albums were located on drives, which can be inaccessible sometimes, Picasa removes information about them from its records. That is why I moved all my photos to the same, disk where Picasa is located itself.

Heiko said...

I've tried this with Picasa 3 beta, but no luck - the application keeps removing the .pal files no matter what I do :-(

Unknown said...

This will not work, as described, for Picasa 3. It keeps its files at different location, that Picasa 2 did.
Probably, you can try to copy the whole folder with Windows Picasa albums (its databases alltogether, not one file at a time) to a new location in Linux and then fix the paths inside album files.

Heiko said...

Thanks Victor, I tried that too (copying both Picasa2 and Picasa2Albums from the Windows machine) but no luck. Initially the albums with thumbnails showed up, but when Picasa was finished rediscovering the pictures and rebuilding thumbnails (>36K pictures...) the albums disappeared again.

I just posted a note to the Google-labs-Picasa-for-Linux group, hoping that there may be other suggestions.

I'll play with this a bit more, may potentially downgrade to version 2.7 and see if I can get your original instructions to work for that before going back to beta 3.