When I performed my search for the perfect photo sharing solution, I fell in love with the Picasa desktop application. I even discovered that there is a linux version. However, as you’d likely expect, it didn’t really play nice as far as uploading photos to any photo sharing site other than Google’s Picasa Web Albums.
On windows, there is a great solution called picasa2flickr which passes the desired photo’s to the windows Flickr Uploader. Again, for obvious reasons, this doesn’t work well on linux.
So, having determined that it wasn’t worth my time to pursue trying to get Flickr uploads working from Picasa on Linux, I started evaluating many of the other native options on linux, such as digikam and fspot. While these more easily uploaded to Flickr, and had open API’s, none of them worked quite the way I wanted, so I abandoned my search for a good solution.
Then, on a whim I did a Google search just a couple hours after Andy O’Neill made a blog post about a button he wrote to import photos to Flickr from the Linux version of Picasa, named picflick.
I eagerly (re)installed Picasa3 on my Gentoo box using a beta ebuild found here. Then installed his button.
After playing with it for a bit, I realized a few things didn’t quite jive for me.
1) The script automatically resizes the image before uploading it to Flickr. I prefer to upload all of my images at their original resolution, so this was a bit of a road block for me.
2) The script used a Perl module to upload to Flickr. For the life of me, I couldn’t seem to figure out how to get it authorized with my Flickr account to actually permit uploads. I’m sure if I spent a bit more time and read a few more manuals I could have gotten it right, but it didn’t quite work “out-of-the-box” for me.
3) I’d prefer to see the progress being made, rather than the beeps and tray notifications that Andy’s script provided.
So, I stole the key part of his script, the part which translates Windows paths to *nix ones, and broke down the rest to simply pass the photos on to my preferred linux Flickr uploader, KFlickr
Here’s the contents of my script, including the win2native function written by Andy.
#!/bin/bash
DEBUG=1 # debug to $LOG
LOG=/tmp/picflick.log
PICASA_WINE_DIR="$HOME/.google\/picasa\/3.0\/drive_c" # Relative to $HOME
PICASA_WINE_DIR_NATIVE=`echo $PICASA_WINE_DIR |sed 's|\\\\||g'`
function debug() {
if [ $DEBUG -eq 1 ]; then
echo "$*" >> $LOG
fi
}
# wine2native(): convert wine filename to native linux filenames
# Arguments: _name_ of variable which holds path
# Example: wine2native file # not wine2native $file
function wine2native() {
VAR=$1
eval "VAL=\$$1"
debug "Wine path: $VAL"
# use '|' to delimit the paths
VAL=`echo "$VAL" | \
sed "s|C:|$PICASA_WINE_DIR|" | \
sed 's|\\\\|/|g'`
debug "Source file: $VAL"
eval "$VAR=\$VAL"
}
# check we have the required dependencies
which kflickr > /dev/null || die "You need to install kflickr"
file=$1
wine2native file
DIR=`dirname "$file"`
EXT=${file##*.}
debug "START_UPLOAD"
for file in "$@"; do
wine2native file
KFLICKR="$KFLICKR $file"
done
debug "Launching kflickr with the following args $KFLICKR"
kflickr $KFLICKR
debug "Done"
Now when I click the “Flickr” button in Picasa, it brings up the KFlickr app with all the pictures I selected ready to upload. Thanks for the inspiration, and code bits to make this work Andy, I was too lazy to actually figure out what was necessary to pull the image paths from Picasa and use them.
#1 by Andy O'Neill on December 14, 2008 - 11:05 pm
Hi!
Good idea! I have to resize my photos because I’m on mobile internet at the moment. I had tried replicating picasa2flickr using jUploadr but I couldn’t figure out how to pass the files on the command line. If KFlickr works well then that’s almost certainly the best way.
And yes, the beeps are gratuitous! What can I say, i was bored.
#2 by Dale Strickland-Clark on December 15, 2008 - 5:53 am
I think the wine2native function is already provided by a standard wine module called winepath. That would simplify it a little.
#3 by Joel on January 29, 2009 - 5:20 pm
Hi,
this sounds great. but after installing picflick and changing the script to your version, selecting a photo and clicking on the “Flickr” button, nothing happens.
I’m using picasa 3 build 57.4402 on ubuntu.
The /tmp/picflick.log doesn’t exist.
Any idea on why the button isn’t running the script?
Thanks.
#4 by Joel on January 29, 2009 - 5:57 pm
I’ve got it. The latest version o kflickr doesn’t allow photo paths from the command line.
I’ve changed from kflickr to postr and it works great.
Thanks.
Error from kflickr:
joel@pav:~$ kflickr /home/joel/.google/picasa/3.0/drive_c/windows/temp/Picasa3/temp_33/hpim2696.jpg
kflickr: Unexpected argument ‘/home/joel/.google/picasa/3.0/drive_c/windows/temp/Picasa3/temp_33/hpim2696.jpg’.
kflickr: Use –help to get a list of available command line options.
joel@pav:~$
#5 by Chris on June 3, 2009 - 5:05 am
Thanks for the script, works great for me. What is the license on it?
#6 by Risto on August 2, 2009 - 12:54 am
Hi everybody — looks great but I’m not able to get it to work with Kflickr (apparently due to what Joel there said) but I’m not getting postr to work either. Postr works otherwise, but I suppose I haven’t altered the script correctly. I couldn’t find man pages for postr – would anybody care to let me know how to alter the script to get postr to upload the pics? Thanks! Postr will upload pics fine if I launch its GUI but I can’t seem to get Picasa to launch it. I’ve changed the Klifckr parts of the script to refer to postr, but no luck yet.
Joel: Could you please post how you changed the script? Thanks.
This is Ubuntu 9.04 and Picasa 3 beta.