At the Hadrian Hotel

At the Hadrian Hotel

Monday, May 21, 2007

Don't use Preview on the Mac to write EXIF keywords

If you read this blog, you may have realized by now that I'm a fan of flickr. As I write this, I have 791 photos uploaded to flickr. One of the things I like about flickr is the ability to tag photos, and one of the features of the flickr uploadr (buy a vowel already :-) ) for the Mac is that it will use EXIF (IPTC, really) keywords as tags for uploaded photos.

I've been using Phil Harvey's excellent exiftool to do all sorts of header manipulations as well as jhead to reset the filesystem timestamp once I'm all done mucking around with the file. Not too long ago, I discovered that the Preview application on the Mac will let you set keywords as well. Even though I am a command line kind of guy, I liked the idea of setting keywords for an image while I was actually looking at it. So I went through and added keywords to about 50 pictures. I then went to reset the date using jhead, and it complained about the EXIF header directory. I used exiftool to take a look, and it told me there was a problem with the IDF0 directory. Hmmm....

I contacted Phil to ask him if he could enlighten me at all on the problem. He was kind enought to respond almost immediately with an explanation of the error, a way I could find it myself (use 'exiftool -htmldump0') and even a way to fix it! Talk about customer service. Thanks, Phil!

It turns out that in the process of writing the keywords to the .JPG file, Preview would delete the YCbCrPositioning tag from IFD0 but not update the entry count for the IFD. That would corrupt the structure for pretty much everything following the now missing entry. This turns out to be a fair amount of stuff.

Phil suggested that I open a case with Apple, so I gave them a call. After spending about 10 minutes trying to explain what an EXIF header was, why it was important, and what Preview was doing to damage it, the woman at Apple put me on hold. When she came back, she said that they did some testing and since there didn't seem to be a subsequent problem with iPhoto and iDVD, there was nothing she could do for me. Grrrr....

I spent a few more minutes trying to explain why having an Apple application corrupt their users' data was a bad thing. She finally gave in and transferred me to an application specialist. I had to spend some time with him explaining the whole problem again, including the bit about my disappointment with the original "it works for us" response I received. I then remembered that Aperture was an Apple product that might actually care about the contents of the EXIF header and mentioned this to him. I was told to call back in a few days to see if he was able to find out anything useful for me.

I called back today and spoke to the specialist. He said that he had discussed the problem with the product engineers and that they knew about it. They told him that there are no plans to fix the problem at this time and the work-around is to not use Preview to set keywords in photos. As you might imagine, this was not exactly the response I was hoping for. However, in light of the initial response I got when reporting the problem, I probably should have expected it. Sigh....

If you want to try this at home, here's what to do. First, make a copy of the photo you want to work on. Open the copy in Preview and type <APPLE>-I (type 'i' while holding down the "Apple" key). A window will pop up with 3 tabs, the third of which is "Keywords." Click on that tab and then the "Add" button in the bottom of the window. Do this as many times as you want and then exit Preview. You will be prompted to save you changes, which you should do.

Now, open up a Terminal window and 'cd' to the directory where the photo files reside. Run 'exiftool -htmldump0' against the original photo and redirect the output to something ending in ".html." Do the same thing with the modified photo, using a different filename for the output, of course. Back in the GUI, double-click on the 2 ".html" files and compare the output. Scan down the right side of the pages looking for "IDF0-" entries. You should see "invalid IFD entry" listed for the modified photo. If you look at the page for the non-modified photo, you should see a whole bunch of information about your photo that is now lost in the modified image. It is possible to update the "IFD0 entries" field to get back most of the missing information, but it is not for those uncomfortable with the command line....

Thursday, May 10, 2007

Backing up your Google Calendar(s)

I've been mucking about lately with ways to synchronize my various Google Calendars with iCal on my MacBook. The latest method I've been working with is gSync, which seems to now work almost just the way I want. Of course, when you're playing around with your all-important calendar data, you want to make sure that you have a backup (or 2 or 3) in a safe place. To that end, I wrote a quick hack of a csh script to slurp my Google Calendar data to a safe place. The script will keep up to 8 versions of the calendar data for a given day, in case you tend to experiment a bit too much.

I include the script below for any of you who may wish to do the same type of thing (that's all of you, right? - you know what happens when you don't back up your data!). Replace the ALL_CAPS stuff with values that are appropriate for your situation. I hope this helps!


#!/bin/csh

cd DIRECTORY_PATH_FOR_BACKUP_FILES

set today=`date +%Y%m%d`

foreach i (GCAL_1 GCAL_2 GCAL_3 GCAL_4)
foreach j (7 6 5 4 3 2)
set current=`expr $j - 1`
if (-f gc-${i}-${today}.ics.${current}) then
mv gc-${i}-${today}.ics.${current} gc-${i}-${today}.ics.${j}
endif
end
if (-f gc-${i}-${today}.ics) then
mv gc-${i}-${today}.ics gc-${i}-${today}.ics.1
endif
end

set verbose
curl -o gc-GCAL_1-${today}.ics 'GCAL_1_PRIVATE_ICS_URL'

curl -o gc-GCAL_2-${today}.ics 'GCAL_2_PRIVATE_ICS_URL'

curl -o gc-GCAL_3-${today}.ics 'GCAL_3_PRIVATE_ICS_URL'

curl -o gc-GCAL_4-${today}.ics 'GCAL_4_PRIVATE_ICS_URL'

unset verbose


Technorati Tags: , , , ,

Wednesday, May 02, 2007

You are Here

Can you find your online home on this map? Boing-Boing and Cory Doctorow's Baloon can be found in the "Blogipeligo" with Stallman's Airship just below MIT. Bonus points for finding the Make Blog.

xkcd - A webcomic of romance, sarcasm, math, and language - By Randall Munroe


Technorati Tags: , , ,