Change Your Picasa Image Titles
I've had a problem since I created the Pictures section of my website and that is that my individual image pages are not included in my site's Page Count according to Google (see what I mean). This is a problem since I have a few thousand images and they would greatly increase the number of pages on the site. I figured that since I have unique content on each one (the image description and any comments entered), they should count. I brought this up to an SEO-specialist friend of mine and the first thing he pointed out is that the page titles are virtually identical across a single album. This is because I use the image title according to Picasa, which is the filename when I uploaded it to Picasa, which is whatever my camera named it or whatever generic name I came up with when I imported them from the camera. I couldn't think of anything better to use for the title and unfortunately Picasa does not offer an easy way to change the image titles.
The answer to my problem is the Picasa Image Name Updater by yours truly, Cameron Hinkle. Harnessing the power of my Lightweight PHP Picasa API, I whipped up this handy little app in just about 12 hours. Now I can update images in my Picasa account at my every whim- and you can too! I created it using AuthSub, which means you sign in to your account on Google's site and then just grant access to my app. You then type in the account you want to update, select an album, and start updating image names! I tried to model the interface after Picasa's web interface for entering captions, although I'm not a Javascript programmer so I didn't use any AJAX.
This was a great exercise in eating my own dog food. I was happy to find that things went relatively smoothly and I was able to do all the backend programming in about seven hours, which is pretty solid given the complexity (yes, that means the style took me 5 hours...I'm so bad with CSS it isn't funny). If you want to have nice-looking image titles on your account, try it yourself and feel free to leave any feedback you have here. I'd love to know what people think.
Comments
Nice work! Just tested is on one of my albums and it is working perfect.
Picasa Version 3.3, Now With Server-Side Caching
The Lightweight PHP Picasa API bug list is finally empty and that can only mean one thing, a shiny new version! Four months have passed since the last version and it's time for another iteration. Aside from one big new feature, this version largely fixes a series of small bugs. Here are the high points:
- Implemented Server-Side Caching (Issue 6)
- Fixed bug in Picasa.getImages() where keywords couldn't be searched when ordering the feed (Issue 15)
- Added "weblink" field to Accounts, Albums, and Images (Issue 17)
- Added Bounding Box search for images (Issue 18)
- Modified Exception classes to print a stack trace when thrown (Issue 19)
Implemented Server-Side Caching
This had been a feature request for a long time and I always thought it would be too difficult to implement but I finally realized it could actually be very simple. The Picasa Data API that the PHP API is powered by just uses XML documents to transport information about a Picasa account. My API simply parses those documents and puts the information into PHP objects. The solution to implement caching was very obvious, I just store those XML documents on the server and check to see if they exist before asking Google for them. This was all very easy, in fact, and the difficult part was making sure it worked securley (ie; you probably don't want to cache Private feeds) and was user-friendly.
Before I dive in to the nitty-gritty, here's the good news about caching: it's all implemented for you in Picasa.php. As long as you're not creating other objects on your own, you shouldn't need to think about it. In case you do, I'll go a bit more into detail.
The cached documents are stored, by default, in your include path, in a directory called "picasa-api-cache". I store them in the include path to make sure PHP has access to them. If the directory doesn't exist, the API attempts to create it. If it succeeds, caching is enabled immediately. If it fails, Caching is turned off and you'll never hear about it again. To see if Caching is working, visit some of your pages that access an Account, Album, or Image, then go to the root of your include path and check for the directory "picasa-api-cache". If it's there, look inside and see if there are any files there. The files look like a URL with all the slashes and question marks replaced by dots. If the directory doesn't exist or its emtpy, caching is probably not working. The easiest way to troubleshoot it is to turn Logging on somewhere in your code, which is done with he following statement (you'll remember this from Version 3.2):
Picasa_Logger:getLogger()->setEnabled(true);
You should then see logging statements telling you what is wrong with Caching. The most likely causes are:
- PHP doesn't have access to create the "picasa-api-cache" directory. In this case you should create it yourself.
- PHP doesn't have write access inside the picasa-api-cache" directory. In this case you should change the permissions on the directory.
Just like the Logging class introduced in Version 3.2, the Cache class is created as a Singleton. So whenever you want to access the cache (which you may never need to do in your client code), you just call Picasa_Cache::getCache() and you'll have the Cache object. You can then call any of the public methods inside the Picasa_Cache class. For instance, you can disable caching, set the path that cached files are stored at, and set the amount of time before cached files expire in your client code (set to two hours by default). At the top of any PHP page that uses the API, you would call the setter for the field you want to modify. If you don't want to remember to do that in your code, you can go into the API and modify it directly. To do this, go to Picasa/Cache.php and update the static private members defined at the top of the class. The cache path is always created inside the include path so if you want to change that behavior, you'll need to update the constructor method inside Picasa_Cache, which is very easy to do.
The last thing to know about the Cache is the way it's implemented in Picasa.php. Basically all the methods that get Accounts, Albums, Images, ImageCollections, Tags, Comments, or Authors all implement caching. For methods retrieving a list based on a set of criteria, the feed is always cached when the visibility is set to "public" (which is the default). This so you don't go in as an authorized user, cache a bunch of private albums and then when an unauthorized user requests the albums, they get the private ones as well as public ones. For the Picasa methods where visibility is not a search criteria, the feed is always cached when the Picasa::$auth member is null. If you don't authenticate the instance of Picasa you're using, it will always be null. If you have authenticated it and you want to utilize the cache in such a call you can either call Picasa::clearAuthentication() or if you'd rather not throw away your auth, just instantiate a new Picasa instance, don't authenticate it, and use that to fetch the album.
Fixed Bug in Keyword Search
Due to a bug in the Picasa data api itself that doesn't allow ordering of images in an image search by upload date, I was forced to introduce a work-around in version 3.2. When I implemented this, I did it a little sloppily and killed keyword searching (thanks to Google Code user Gaitan for finding this and reporting it). This was an oversight and a quick fix. Search away!
Added Weblink Field
Special thanks to Picasa API user Ruben Woudsma who noticed the usefulness of having a link back to the Picasaweb page for an image. In fact, he wrote the code to add it himself and sent it to me. Open Source programming at it's best. Anyway, you can now call getWeblink() on a Picasa_Account, Picasa_Album, or Picasa_Image object and it will give you the URL to that object on the Picasaweb site.
Added Bounding-Box Search
This was relatively straight-forward, Google introduced searching by Geo-coordinates and I just added it to the API. You can pass 4 bounding-box coordinates to Picasa->getImages() in the $boundingBox parameter and you will get back images within those coordinates. It should be a single string with four coordinates seperated by commas.
Modified Exception Class
I have to plead ignorance on this one, I had no idea PHP was so self-aware! Now when an exception is thrown, a stack trace is printed. This was simple to do using PHP's built-in getTrace() method.
That about sums up the bulk of the changes for this round. If you find something not working, kindly enter a bug and it will get addressed. If you have a question, first take a look at the documentation and if you're still stumped, email me. And if you don't yet have the latest version, go get it!
Comments
Well I'm glad everyone is liking the new version. And mr.bmc, I took your advice and added the project to SVN via Google Code. You may now go to the Google Code site and checkout the latest version.
Not having this project under version control was my dirty little secret! I know, I know, what would Joel say? :P
Awesome work dude, I had this working in 3 hours:
http://www.reposteria.cl/fotos.php
:D
Thanks!
Great work Cameron!!
Sweet. Your class beats up Zend and takes its lunch money.
Yeah that is a great idea. I will work on that and update here when it's available.
Do you have plans to allow SVN access via Google Code?
http://picasaphp.googlecode.com/svn/trunk/
Day Two of the API's latest release and already a critical bug! You may have noticed the cache folder gets created one level above your include path if your include path doesn't have a slash at the end (Issue 20). Well I've fixed it and uploaded the new version so if you downloaded it since the release you'll probably want to do it again, or just make sure your include path has a slash at the end. Oh and my QA staff have all been fired!
Happiest Place on Earth
Last Saturday my good friend Erik Hiller got married to his fiancee Kim (you'll remember them from such albums as "Arcadia Beach Roadie 2007"). The wedding took place in sunny Los Angeles, California so Debbie and I used it as an excuse to see the sights in SoCal. We did Disneyland the first day, then made a circle around LA County by hitting the Griffith Observatory, Hollywood Blvd, Santa Monica, and as much of the PCH as we could stand in rush hour. Finally Saturday was the wedding itself. If you're interested in pictures, go ahead and take a look.
Disneyland was great fun as usual and especially fun since it was Debbie's first trip there. We were a little disappointed at first to see the park was only open from 10:00 am to 8:00 pm (about 3 hours shorter than most days) but when we got to the park and saw the 20 minute lines were were more than happy to have picked that day! Seriously, the longest line we waited in was the Finding Nemo submarine (which was better than expected but doesn't crack my Top 5 rides or anything) and that was no more than 25 minutes. The downside was that we did not get to see the fireworks or Fantasia but getting to ride every ride we wanted to in about 10 hours was worth it! In the future we will continue to aim for the after-Spring Break/before-Summer Break window. We even had time to visit California Adventure and were glad we did. The Hollywood Tower of Terror was a little bit hyped but was nicely polished and offered a great view of the parks (for about 2 seconds while you're screaming for your life). Soarin' over California, on the other hand, was AMAZING. I did not think it would be that convincing but it may have been my favorite ride of the whole day. Just phenomenal.
The next day was nice to get out and see more of the city and a few landmarks, although Hollywood got a big thumbs-down from Debbie. Vendors getting in your face and crazy people dressed as funny characters...Debbie and I were both pretty uncomfortable. The Griffith Observatory is a nice place to spend a few hours, especially if you're a science geek. It's got a great view of the city and the Hollywood sign as well. Another great view is from the top of the Ferris Wheel on the Santa Monica pier! It was a little freaky but I'm glad we did it.
Finally the wedding was Saturday and was another amazing view of the city. Probably the best venue I could possibly think of for a wedding. It was great to be able to be at Tiny's wedding and to finally get our crew back together for a day. And if that wasn't enough, we spotted an amazing look-alike at the wedding. We were all pretty certain this was the guy from Season 2 of 24 and Lost's Christian Sheppard, but it turned out to just be a friend of the bride. You can't disagree, though, the resemblance is uncanny.
It was a great trip. Debbie and I got to see a lot of the city we had never seen before and had a really fun time. We also walked away with a few key travel tips that I will share with you now. First, when given the option, fly JetBlue. 36 channels of DirectTV, live Sirius XM radio, extra leg room, no fees for one checked bag, and the cheapest tickets I can find. I was blown away by this airline. Second, when given an option, I'll rent through Enterprise. Again, the cheapest I could find and they upgraded us to a Focus for free! Third, if you are hungry at Disneyland and don't like seafood, go to the Carnation Cafe on Main Street. Good food, reasonable prices, short wait-times, and a very friendly staff. And lastly, Embassy Suites offers UNLIMITED BACON EVERY MORNING. Yeah, they have other stuff too (pancakes, eggs, cereal, toast, etc) but the bacon overshadowed all.
Congratulations to Erik and Kim, we're very happy for you. And thanks for giving us a reason to visit LA! We hope to be back soon.