advertisement

Article:
  Cleaning iPhoto
Subject:   Use the Force, Luke.
Date:   2004-02-28 08:21:04
From:   hhas
tell application "iPhoto"
remove photos of photo library album whose width < 200 or height < 200
end tell
Full Threads Oldest First

Showing messages 1 through 5 of 5.

  • Use the Force, Luke.
    2005-01-21 11:07:30  pixel [Reply | View]

    ok, so that might be shortened, and it MIGHT work faster, but it sure eats up memory for some reason. I killed iPhoto after it ran for 20 minutes, was using over 500MB of physical and 1.5GB of virtual memory... and it was steadily rising. Anyone have any ideas?
    • Use the Force, Luke.
      2007-02-15 17:19:36  paulskinner [Reply | View]

      In this shorter version you're asking Applescript to first iterate through every item in your library and retrieve the properties from each one of them, then compare two values from those properties to your given values. After this you then have it store the items that match the range you test for into a list. It may be storing a reference (memory cheep) or it may store the value (memory expensive) of the database entry.

      This is indeed very inefficient despite being concise.

      This version is more memory and processor efficient. I ran it against my 22000 image library and checked 5500 in ten minutes.


      tell application "iPhoto"
      tell photo library album
      set c to count of photos
      repeat with myIndex from c to 1 by -1
      tell photo myIndex
      set {thisWidth, thisHeight} to {width, height}
      end tell
      if thisWidth < 200 or thisHeight < 200 then
      remove photo myIndex
      end if
      end repeat

      end tell
      end tell


      • Use the Force, Luke.
        2007-04-14 16:59:47  sttkaufman [Reply | View]

        Great applescript thanks. Is it possible to do the "remove duplicate" script written in Perl as an Applescript. That is my real problem. Thousands of dulpcates from merging three semi-duplicate iphoto libraries on three machines. Now I have a mess on my hands. I would like to search for dulpicate images that may or may not have different names, and choose the largest res, keep that one, and throw out the others. Any thought or hints? Any one tried this in AppleScript?

        Stephen
      • Use the Force, Luke.
        2007-02-15 17:26:30  paulskinner [Reply | View]

        I forgot to mention that if you're running iPhoto on an older or lower-powered system you should go to the appearace pane of the iPhoto preferences and turn off drop shadow and outline options for a substantial speed improvement.

        Seeing the dates on this article I hope you're back in the states Brian, but perhaps not... if you're still over there, keep your head down.
  • brian d foy photo Use the Force, Luke.
    2004-03-01 22:58:44  brian d foy | O'Reilly AuthorO'Reilly Blogger [Reply | View]

    Thanks for the reduction. :)

    I'll have to test this to see if it comes out faster, and I suspect it will.