Small Hack to upload to Picasa Album

Plug-ins, add-ons, skins, icons, templates and other downloads. Contributions are welcome.

Moderators: XnTriq, helmut, xnview

Post Reply
calli
Posts: 1
Joined: Wed Dec 17, 2008 1:22 pm

Small Hack to upload to Picasa Album

Post by calli »

Hi,

I like the picasa web photo album, however I dont like Picasa itself. The Uploading on the webpage is to complicated. So I hacked(!) together a small python snippet which is using the Google-API to upload an image from within XNView.

See: http://code.google.com/intl/de-DE/apis/ ... t_lib.html

All I have to do now is press ALT-1 with one or more images to upload. I used "Open With..." (hope thats the term in the english version) and pointed it to my .bat

pifoto.py

Code: Select all

# pifoto.py
# use at own risk!

import gdata.photos.service
import gdata.media
import gdata.geo

import sys
import os

# Fill in!
email = "cw@XX.YY"
password = "YYYY"

#print "Retriving information ..."
#albums = gd_client.GetUserFeed()
#for album in albums.entry:
#    print 'Album: %s, number of photos: %s, id: %s' % (album.title.text,album.numphotos.text, album.gphoto_id.text)
#    print '/data/feed/api/user/%s/albumid/%s?kind=photo' % ("default", album.gphoto_id.text)
#    photos = gd_client.GetFeed('/data/feed/api/user/%s/albumid/%s?kind=photo' % (username, album.gphoto_id.text))
#    for photo in photos.entry:
#        print 'Photo title:', photo.title.text

# Fill in!
# get the id with the code above!
defaultalbumid = "YYYYYY"


username = "default"  # let this alone...

if len(sys.argv) < 2:
	print 'Nothing to do!'
	sys.exit()
else:
	for image in sys.argv[1:]:
            print "Argumente: ",image

print "Logging in: ",email

gd_client = gdata.photos.service.PhotosService()
gd_client.email = email
gd_client.password = password
gd_client.source = 'pifoto'
gd_client.ProgrammaticLogin()


for filename in sys.argv[1:]:
    path,image = os.path.split(filename)
    picfilename = path+"\pic_"+image
    print "Uploading photo: ",image, path
    nconvert = '"C:\\Programme\\XnView\\nconvert.exe -out jpeg -resize 1600 1200 -ratio -sharpen 12  -rtype lanczos  -q 90 -o %s  %s' % (picfilename,filename)
    os.system(nconvert)
    album_url = '/data/feed/api/user/%s/albumid/%s' % (username, defaultalbumid)
    photo = gd_client.InsertPhotoSimple(album_url, 'New','',picfilename, content_type='image/jpeg')
I also made a .bat (I think there must be a way without the .bat):

pifoto.bat

Code: Select all

C:\Programme\Python25\python.exe pifoto.py %1 %2 %3 %4 %5 %6 %7 %8 %9
You can see it is a terrible hack! Too many pathes and dependicies have to be changed, however I think it may be a start for someone else to make a good thing out of it ;-)

Things I would like to add but don't know how:

- get descriptions and other tags from XNView to the script
- mark uploaded photos in XNView
- do the resize in XNView
- ...

Carsten
SeaWolf
Posts: 1
Joined: Tue Nov 06, 2007 3:08 am

Post by SeaWolf »

It's a great idea, even if the end result is a bit hackish. It would be fantastic to see some sort of upload option/addon for XnView that would present you with a variety of services and options (Picasa, Flickr, Facebook etc.).
Post Reply