Download albums/images from Picasa

8. November 2009 20:31

C# Utils  0 Comments

Picasa is an online photo sharing portal from Google. Users from around the globe use Picasa for storing and sharing their photos online. We can view and download images from the album, but only if it is public. We cannot view private albums and also cannot download images from any of the public albums if the owner of the album has denied the access for other users to download the images.

But there is a way from which you can download the images. We are here going to use Google API to achieve this. You can download the Google API for .NET here.

To get started we have to first import the namespaces

using Google.GData.Photos;
using Google.GData.Client;
using System.IO;
using System.Net;

Now here is the method which we are going to use to download the images. The methods takes in two parameters username and the album name. To get the username for the album, check the url of the user profile. For e.g.: Here the username is prashantmx, so the first parameter, username will be prashantmx and the albumname will be superbikes. Point to be noted is that there cannot be a white space between the username and albumname.

private static void DownAlbum(string UserN, string AlbumN)
	string fileName;
	Uri uriPath;
	WebClient HttpClient = new WebClient(); 
	PhotoQuery query = new PhotoQuery(); 
	query.Uri = new Uri(PhotoQuery.CreatePicasaUri(UserN, AlbumN)); 
	PicasaService service = new PicasaService("PicasaAlbumDownloader"); 
	PicasaFeed feed = (PicasaFeed)service.Query(query); 

	foreach (AtomEntry aentry in feed.Entries) 
		uriPath = new Uri(aentry.Content.Src.ToString()); 
		fileName = uriPath.LocalPath.Substring(uriPath.LocalPath.LastIndexOf('/') + 1);
			Console.WriteLine("Downloading: " + fileName); 
			HttpClient.DownloadFile(aentry.Content.Src.ToString(), fileName); 
		catch (WebException we)
	Console.WriteLine("Download Complete!");  


Download: (128.78 kb)

Currently rated 5.0 by 2 people

Comments (0)

Add Comment

Visit to discover Indian blogs Computers Blogs