Joe Maller.com

Date-shifting in iPhoto ’08

I get a lot of requests to add date-shifting support for iPhoto 08 to my iPhoto AppleScripts. But in most cases, the scripts would be completely unnecessary, iPhoto finally built this feature into the application. Here’s how to use it.

Select one or more photos you’d like to adjust, then choose “Adjust Date and Time…” from the Photos menu:

You then change the Adjusted date to the correct time and all the other photos will be shifted to match.

Using this native tool is substantially faster than anything I could do with AppleScript. I’m just kind of sad I never finished up the auto-date difference calculator I was working on.


iPod photo Cache, deleted

Apple Support Document 300225: Photo Sync creates iPod photo Cache:

When using iTunes to sync photos to iPod photo, iTunes creates a folder called iPod photo Cache in the top level of the folder you selected for your photos. Picking another folder to sync does not erase the previous iPod photo Cache.

Depending on how many photos are being synced, the hard drive could fill up.

Drag the folder named iPod photo Cache to the Trash or Recycle Bin.

Sure enough, poking around in there I found cache files from 2005. so I moved some of that clutter over from my old PowerBook to the new MacBook Pro.

Juggling free space is always an issue for me, deleting this folder recovered almost 3 GB.

I noticed this folder while showing Disk Inventory X to a friend.


EXIF and the Unix Strings command

I got an email over the weekend pointing out a bug in my iPhoto Date Reset if an original image contained a single-quote in its name. Most all of my iPhoto images were imported from the camera, so I hadn’t seen this before, but I’m pretty sure I’ve already gotten it fixed.

While fixing that, I did a little revising of the EXIF sniffing script. I was using a one-line Perl snippet to scrape the date out of the first kilobyte of the file. Here’s the command broken across several lines

 perl -e 'open(IMG, q:[ABSOLUTE PATH}:);
 read(IMG, $exif, 1024); 
 $exif =~ s/\n/ /g; 
 $exif =~ s/.*([0-9]{4}(?::[0-9]{2}){2} [0-9]{2}(?::[0-9]{2}){2}).*$/$1/g;
 print STDOUT $exif;'

That worked, but perl one-liners usually need to be enclosed in single-quotes, since AppleScript was filling in the path, single-quotes in the name broke the script. I’m not that fluent in Perl, so there’re probably better ways of doing that.

But then I stumbled across the Unix Strings command. This basically does most of what I was doing. It scrapes a binary file (meaning non-text) and extracts anything that seems to be a string. The output from JPEGs often contains a bunch of gibberish, but right above the gibberish is every unencoded string from the EXIF header.

Using strings, sed for the pattern and head to trim, that somewhat convoluted perl script became this trim little shell script:

 strings [ABSOLUTE PATH] | sed -E -n '/([0-9]{4}(:[0-9]{2}){2} [0-9]{2}(:[0-9]{2}){2})/p' | head -n1

They’re both essentially instant on my computer so I’m not going to bother building a test to figure out which is actually faster.


Flip4Mac bugs and troubleshooting

iPhoto and Image Capture suddenly stopped importing from my digital camera. Same problem using the camera as a reader or my little thumbdrive adaptor. Plugging in my Fuji F10 would immediately crash the Mass Storage component of the Image Capture thingie. I was also having all kinds of trouble sharing my iPhoto library and movies downloaded from the camera would play until the last frame, which was inexplicably all white and would crash QuickTime player. Before figuring out the following I was afraid my camera was broken or the xD card was defective.

It took me a bit of sleuthing to determine that Flip4Mac was causing this. First, I confirmed it wasn’t hardware; the camera worked fine on Michelle’s nearly identical PowerBook.

To try and figure out what was preventing the camera connection from working, I opened Activity Monitor, made sure “All Processes” was selected at the top (I always have that option selected) then sorted the list by Process ID descending. Because Process IDs count up, whatever launched next would appear at the top of the list.

Plugged the camera in and watched. MassStorage popped up, then disappeared, followed by CrashReporter. Fine, now I knew what was crashing. Off to the Console.

In the main console.log, I saw the following lines:Jan 22 22:57:52 joemaller-powerbook crashdump[295]: MassStorage crashed
Jan 22 22:57:53 joemaller-powerbook crashdump[295]: crash report written to: /Users/joe/Library/Logs/CrashReporter/MassStorage.crash.log

These confirm that MassStorage had crashed and show the location of the log file. Use that path to navigate through the log listings in Console.

Crash Reports are 90% meaningless unless you wrote the application. However, they are full of clues. Scroll up from the bottom until you see a line of asterisks, these are the beginning of the last crash report. Below that are some details about the application and a thread-dump of the crash. Below the listing of threads are the components active at the time of the crash.

There were several third party binaries near the top of my list. I unloaded them in order, restarted then plugged the camera in again to see if it was still crashing.

  • iGlasses – fine. (very cool video iChat gadget, fun and useful)
  • DivX: fine, but I use VLC anyway. Deleted, not reinstalling.
  • Flip4Mac WMV Import: Bingo!

Flip4Mac was installed in “/Library/QuickTime/”, with a bunch of other codecs. Removing it solved all the problems I listed above. Later I noticed they included an Uninstaller, here’s yours.

Flip4Mac is a recommended replacement for Microsoft’s discontinued Windows Media Player. There’s a tired old joke in there somewhere. In the meantime, tons of people are complaining about various problems related to this. One posting somewhere claimed the problem was related to DivX being installed, but I still had issues after removing DivX. Something to remember for future troubleshooting; bizarre problems, check for Flip4Mac.

Integrating Windows Media files as Quicktime Components is long overdue. Microsoft deserves some credit for recognizing how good Telestream’s product is and for spending the money to support their work. WMVs have never played as well on my machine before this. However I am worried this instability might be a precursor of things to come, and I hope Flip4Mac won’t break in strange new ways with each subsequent QuickTime point relase.

Telestream has released a v2.0.1 update which claims to fix these issues. After making sure everything was working without Flip4Mac, I installed the update and immedately checked my camera connections. Happy to report it’s all working.

Update: Spoke too soon, movies from my camera ended with white frames again. Uninstalled Flip4Mac and they play fine. 2.0.2 anyone?


Joe’s iPhoto AppleScripts updated for iPhoto 6

I just posted updated versions of my iPhoto Date Manipulation AppleScripts which now work with iPhoto 6.

This is definitely the best version of iPhoto yet, but the biggest positive change regarding scripting is that dates are now read/write properties. Before dates were read-only strings whose format would sometimes vary. Because dates can now be set as AppleScript date objects my long nightmare of UI scripting can finally come to a end. No more need to internationalize ambiguous dates, no more counting interface splitter groups to figure out what was visible, no more “keystroke”, and no more appallingly slow performance.

Another good part is that all my date logic was abstracted using proper date objects, so that all translated perfectly. Once I noticed that dates were finally writable, it took very little time to update the specific routines to work with the new version.

Now I feel like it would actually be worth my time to create Automator actions, the absurdly delicate nature of UI scripting would have previously made that a nightmare.

Share |

link: Jan 22, 2006 1:23 am
posted in: Mac OS X
Tags: ,

iPhoto Bloat and Slowdowns

I got an email today asking if I knew anything about slowdowns in iPhoto due to bloating of the Library.iPhoto index file. I hadn’t heard of it before, but Eric Lindsay, J Kevin Wolfe and the MacInTouch iLife reports have a lot of good background information.

My iPhoto is slow, but not too bad compared to some of these reports. However it does make using it not particularly enjoyable. My Library.iPhoto file is only 35mb (264,395 lines for 10,000 images), iPhoto takes about 15-20 seconds to show photos after launching. Most of my photos came from Sony cameras.

Maybe some of this will be addressed by the new 10.4.3 update.


Joe’s iPhoto AppleScripts updated

I just posted updated versions of my iPhoto AppleScripts which hopefully address many of the problems related to System Events errors.

As I was trying to nail down what caused System Events to throw occasional errors I found a bug which was my fault. If any other windows were open in iPhoto, (info, keywords, Keyword Assistant), iPhoto would sometimes throw an NSReceiver error. All extra windows will now be closed before setting any dates. Apologies for not catching that sooner or thinking to check whether other windows were open. Hopefully that oversight will account for the majority of NSReceiver errors.

All window references should now be numeric, even though I’m fairly sure the window is always called “iPhoto” despite the active user language. (I deduced that from running the application under a variety of languages while internationalizing the date handling, the window title was always “iPhoto” even if everything else was not English and using non-Roman characters.)

iPhoto is now more assertive about coming to front, this should make running from Script Editor easier since dialogs won’t be popping behind iPhoto.

Every System Events command is now wrapped in an try block and a loop. Errors will cause that function to be run again after restarting System Events. I did this in the functions to try and maintain portability, but it made the code much uglier.

Random notes:

iPhoto 5’s adjustment windows are wacky. They report themselves as “AXUnknown”, with a possibly English localized name “HUD”. These windows do not respond correctly to a close window command

iPhoto 4 and iPhoto 2 reversed the numeric index of the date and title fields in the info pane. I must the only person in the world who noticed that. If I remember correctly there was no iPhoto 3. iPhoto 2 is not currently supported, for whatever reason it wasn’t correctly incrementing selections via Apple Events. If it’s a quick fix, I might get that working at some point since I have access to a machine with that version.

Share |

link: Oct 09, 2005 12:30 pm
posted in: Mac OS X
Tags: ,


Next Page »