Thursday, 26 April 2012

How to make Picasa name tags be indexed by Spotlight

I recently rediscovered Picasa and am impressed with its new features - considering it is free. Thanks Google! Picasa is a photo organising and touch-up software and is available for Windows, Mac and Linux (with Wine). However, you still need to be a bit of a geek in order to not get trapped. 

What I particularly like about it is that it leaves all photos in the place I put them and does not store copies in its own folder - as iPhoto does. This makes it easier to share my photos between computers, be able to mange the photos with other software at the same time and allow me to keep the photos in a file structure that is sensible to me - namely in folders by the year in which they were taken and then in a folder for the location or trip to which they belong. Importantly, it has a small footprint on your RAM.


What brings me to write about Picasa is its nifty naming and tagging features. Thanks to demand, if you choose so in the preferences, you can now save the names of people to the EXIF data of each JPEG. As I described in my last post, I like to be able to use my operating system to quickly search/display photos and produce slide shows based on the tags they contain. Correctly tagging all of your photos that you have accumulated over your life - if like me you have gone to the trouble of scanning them - can take an equally endless time. The Picasa facial recognition tool makes this task so much easier, if not fun. 

It sometimes comes up with amusing suggestions, particularly if it sees a face on a train or in a plate of food, but really its down side is that it does not recognise your pets and, particularly, people who are not facing the camera! It also tends to miss some people that are facing the camera. And don't bother scanning folders that have many photos with strangers in the background or you'll be up all night ignoring/hiding their faces!

When you first set Picasa up you'll be bullied into agreeing that it scans for photos in a couple of default locations. I forget if there is a way out of this, but I recommend going afterwards to Tools>Folder Manager and selecting only those folders you actually want it to manage. If you would like it to save the tagged people to the EXIF data of your photos (JPEGs only I think), go to Preferences and the Name Tags tab and select "Store name tags in photo". Note, that even if you don't select this option, if you assign any tags or comments to a photo, Picasa will anyway leave its print in the EXIF data of the photo and a unique ID number, which helps it link the photos to its database.


Picasa stores the name tags under a tag name that is not indexed by Spotlight or, probably, the Windows indexer. Thus, it still traps you into using their software so that you are more inclined to upload your photos to share on their server. My solution to this, as before, is to duplicate the name tags to OpenMeta and Windows format tags. And here is my Bash script, that does just that, on my Mac.

[edit: original code with the typo has been replaced with the following github snippet]

To use the script, copy and past it into a text editor, save it as where you saved the other script, also make this script executable by going to the location in Terminal and entering chmod +x and running the script as, e.g, -r DirName

  1. Make sure you have backed up your photos just in case something goes wrong!
  2. The script will only work properly if in my other script,, you replace the exiftool option -overwrite_original  with -overwrite_original_in_place. If you don't, the new OpenMeta tags mysteriously disappear if you view them with Tagit.
  3. Unfortunately, because my script does not handle spaces in tag names, this script will not either. Perhaps someone can help me sort that with a line or two of code. To enable this script to handle spaces as far as transferring the tags to OpenMeta, simply uncomment the two lines marked with "use to handle spaces"  (delete the first "#" in the line) and comment out each previous line. This apparently is not recommended by the OpenMeta help file but I think the help file is probably either inaccurate or out of date! Otherwise, in the mean time, tag names are just as search able if you enter them as AlbertEinstein or ChrisR. 
  4. Close Picasa before running script otherwise it might not recognise all of the changes you have made to the tags.

Happy Tagging!

Sunday, 15 April 2012

How do you find your favourite photos?

So, you've been won over by digital technology and, on holidays, find yourself endlessly snapping away with your camera. It does not matter how many photos you take, because it is free and you can delete the bad ones later. But what about the ones that are not bad and not that good? Ten years later you find that you have accumulated between 10 and 100 thousand photos. The few slide-shows you put together to show your mother were created with software on another computer, which you gave away when you had a brief fling with an iPad. How do you find the best photos of you and your dog? Good luck! 

The problem with using software to organise your photos is that it either costs money, is not available for all operating systems and most importantly you are trapped. All that work you did organising your photos is locked away in a piece of software that you might one day not like or could be discontinued or not supported on your next computer. Your photos should live longer than your computer. We need a better way. 

Tagging - its all about tagging!
In case you hadn't noticed, Windows 7 and Vista have tagging facilities built in. What you may have not known is that there are many free programs to provide this feature to other operating systems, such as Mac OS. Tagging is here to stay and one day tagging will be as standard as tabbed browsing. This is what tagging is:

Many computer files, such as photos and movies, enable one to hide written text inside them without it being normally visible. This enables one to set keywords and even descriptions and ratings to help one find them again. For example, if you went on a trip to New York you could enter the keywords "New York" and USA. On photos that contained you or your dog you can enter your names. Rating your photos might seem a faff, but if you rate the best with 5 stars and the better ones with 4 it makes setting up a slide show a doddle.

On Windows and Mac, by simply typing tag:USA Rover in the file browser search box would almost instantly bring up all the photos on your computer (or specified folder) of your dog, Rover, in the United States. On Windows, to show only the best photos, also enter something like rating:5 stars  or rating:>=4 stars, start a slide show and enjoy.

Tagging on Linux, XP and Mac
I haven't set up the use of tagging on my Linux netbook yet, but solutions exist, such as using Tracker and digiKam. I also gather that it will not be long before solutions with come bundled with the popular Linux distributions. There is TaggedFrog for Windows XP users, but again I have not used it. 

I usually use a Mac that is running Leopard and, unfortunately, I am disappointed that Apple are behind in the tagging game - probably because they want to trap their users in iPhoto, which I no longer want to use. I am not going back there. Particularly, as I like to sync my Linux netbook before I take it on an adventure. I still use it as my gps navigator!

Currently my favourite tagging software for Mac is Tagit, where one can drag selected photos to its icon in the Dock to set their tags and rattings. When the tags are set, as above, 
  • Enter something like  tag:USA Rover, in the search field in Finder. 
  • To select the best photos the command is starrating:5 or starrating:>=4  
  • To start a slide show in Leopard, select all of the photos you want to view and hit the space bar!
Sharing Tagit tagged photos with Windows users
The limitations of Tagit are that it does not support comments, one cannot easily review all of the changes one has made and it uses another method of storing the meta data than Windows that seems get lost more easily. For example, by attaching a photo directly to an email to send to another mac user the tag data is lost. To preserve tags when emailing you should zip the photos up together with the folder that they are in. I presume, because will include the hidden .DS_Store file. 

If you are happy always sticking with a Mac for now, you might be ok with only using Tagit. However, if you'd like to be able to share your tags with Windows users, the good news is that is already possible if you are prepared to learn a bit of Bash. You'll need the following command line programs
  • openmeta - to read or modify Tagit tags
  • exiftoool   - to set the EXIF data of photos
Both are free and easy to install and straight forward to use if you are familiar with using Terminal. To save you the time, I'll share my Bash script that copies Tagit tags to the EXIF data of photos so that they are also visible on Windows. Feel free to use and modify it as you like. I am no expert and can't guarantee it will do as expected so I recommend you always back up your photos before you run it. 

Novis instructions for how to use the following script:
  • You can copy/past it into a text editor and save it, perhaps in Pictures as
  • Open Terminal and change directory to Pictures (or wherever you saved it) by entering the command: cd Pictures
  • Make the script executable by entering the command: chmod +x
I organise my photos first by year and then by location or event. To copy all openmeta data to EXIF format for the year 2012 and recursively for all contained folders type the following command:
  • ./ -r 2012

  1. to access the script from any location you can add it to your path, such as putting it in the folder /usr/bin/ or by specifying your own user path
  2. When I need it, or if any one requests, I shall write a similar script to copy the tags in the other direction.
  3. The title of this post was a genuin question. Please let me if you have any better (free) solutions!

om2exif - the script


# BUGS: does not handle spaces in file names with -r and -p options
# NOTE: does not delete existing tags or rating if not set by openmeta

     om2exif -- copies openmeta tags to exif data readable by windows

     om2exif [OPTION] [DIR/FILE]

     -r   recursively copy tags for files in directory
     -n   non recursively copy tags in direcory
     -p   path to single file to copy tags

if [ x$2 = "x" ]; then
echo "$usage"

if [ $1 = "-r" ] ; then 
fileList="$(find $2 -name *.[jJ][pP][gG])"
elif [ $1 = "-n" ]; then
elif [ $1 = "-p" ]; then
fileList=$2  #$(echo $2 | sed 's/ /\\ /g')
echo "$usage"

for file in $fileList; do
echo updating "$file"
omkeywords=$(echo $(openmeta -p "$file" | grep tags) \.) 
omrating=$(openmeta -p "$file" | grep rating | cut -d ' ' -f2 | cut -d '.' -f1) 
echo $omkeywords
echo rating: $omrating
# translate keywords
while [ $(echo $omkeywords | cut -d ' ' -f$i) != "." ]; do
newtag=$(echo $omkeywords | cut -d ' ' -f$i)
if [ $i = 2 ] ; then
subject=$subject" -subject="$newtag
lastkeywordxmp=$lastkeywordxmp" -lastkeywordxmp="$newtag
i=$(( $i + 1 ))
# translate rating
if [ $omrating = "none" ]; then
rating=" "
exiftool -overwrite_original -xpkeywords=$xpkeywords $(echo $lastkeywordxmp $subject $rating) "$file"
echo "done"
echo " "

Useful commands
When you view the photos as described above they can be ordered by date or name. Ordering by name does not work if you have more than one type of camera. Ordering by time does not always work as the creation and modification times can/will be changed when edititing or if you scanned the photos from film etc. exiftool is useful here in that it can recursively rename your digital photos to incorporate the time and date they were taken. The following are the options I use. A comprehensive list of examples, such as for correcting creation or modification date given in exiftool's manual and online.

exiftool -r -ext JPG -d %Y.%m.%d_%H%M.%S%%-c.%%e "-filename<CreateDate" Dir/ # rename pictures

exiftool -r -ext MOV -ext AVI -d %Y.%m.%d_%H%M.%S%%-c.%%e "-filename<CreateDate" Dir/ # rename movies

NB: these are two commands spread over four lines. Replace Dir with your own directory name

Thursday, 15 March 2012

Why don't I eat meat?

I wrote this in India before riding a motorbike over a 20 meter cliff. Don't ask me why I did it as I don't remember, but I believe I was pushed - by a bus. I am grateful to be alive but no clearer what I want to do with my life. Many people have suggested that I survived because I have something to achieve on Earth. Perhaps they are right. Perhaps it is to spread my philosophical ideas! Please read.

I have been asked many times in India why I don't eat meat, so I thought I would explain. Having been brought up a vegetarian I never gave it much thought whether I wanted to continue being a vegetarian all my life. As an undergraduate student I couldn't afford to buy meat. As a post graduate I eventually thought through my reasons as to why I should or shouldn't eat meat. The advantages are obvious. Being a vegetarian is difficult because you have to be careful to eat a balanced diet, otherwise you become deficient in something. Every vegetarian needs to be a bit of a nutritionist. As a vegetation you have to be particularly careful to eat enough iron, B-vitamins and omega-3. Actually, as a vegetarian I was a bit of a cheat by supplementing my diet with a little oily fish about once a week (omega 3 and 6) and unlike Indian vegetarians I also eat up to a few eggs a week (includes B-vitamins) and regularly drink Guinness (iron!).

My conclusion was that I wouldn't be a true vegetarian. Although I am a little uncomfortable and even feel a little guilty if I eat meat (not being used to putting animal inside my mouth and chewing on a piece of leg), I am not strictly against the idea. If we look into the animal world, animals eating other animals seems to be the worlds natural way of keeping the population of vegetarian animals in check. But what happens nowhere in nature, other than with us humans, as far as I know, is the imprisonment, or the farming of animals, for consumption. If a pig was human, this would be no less than slavery, but far worse: the animals life is always cut unnaturally short. Many meat eaters point out that if it wasn't for us that the animals would never be given a chance to live. That is the very answer that points at the crux of the problem: does the animal “have a life”? If the animal could ask itself, is it happy, and understand what happiness means, would it say yes? Of course it is difficult, if not impossible to answer this question precisely. But we can at least try and answer the question by learning an animal's body language and comparing its behaviour to how how we feel when we give similar body language. I believe that people who know an animal well can already do this.

I then put forward the question: What nature of a world would I like to live in? One that is based on greed and on a simple philosophy of survival of the fittest, or one that is based on thoughtful decisions that include a sense of responsibility for other human beings, animals and the general environment? I believe that if we are to demonstrate that we have a more intelligent lifestyle than animals, our lifestyle should be sustainable. It is my hypothesis that we can only achieve a sustainable lifestyle if we base our decisions not just on our needs but on the impact they have on the world. I believe that empathy is fundamental for a sustainable future - a lifestyle that does not collapse because it has taken too much too quickly. If we can learn to feel responsible for the welfare of all animals we are well on the way to being capable of living sustainably.

I believe that keeping animals in cages, restricting their freedom such to impact on both their physical and mental health in order to maximise meat production, throws dirt in the face of empathy and cannot be considered part of a sustainable future. There are so many secondary problems that arise due to our greed for meat: obesity, energy inefficiency and the frequent creation of new diseases such as bird and swine flu, to name just a few. Thus, I believe there should not be any space on our plates provided for meat bred on misery, dripping with crude oil, drowned in much needed drinking water and at the cost of dwindling rain forests. If we can happily say that our food does not come with these high price tags, we should not be eating it. Consequently, in the UK, I now only consider eating meat or animal products from free range organically reared animals where the animal is more likely to have been sensitively cared for. I think game, such as venison from wild dear can fit these criteria, but can only sustainably contribute a small part of our diets. If I can't afford to buy such meat, I am happy to live without it and believe anyone can do the same. Meat production should not be included in the food shortage debate.

Photo is of dolls I found above my bed in my guest house room.
It is the last photo I have of my adventures in India.