A success story

Discussion in 'Ruby' started by Gregory Seidman, Mar 10, 2006.

  1. No, this isn't some story about a successful enterprise-level
    intranet/extranet web portal solution done entirely in Ruby (and Rails).
    This is just a story of quick success in doing a simple task.

    Problem: I wanted to create images of a web-suitable size from the images
    in one of my wife's iPhoto albums without taking over my wife's
    computer (e.g. VNC over ssh to take control) since she was using
    it at the time.

    Solution:

    % sudo gem install -r -y iphoto2

    Ruby script (listalbum):

    #!/usr/bin/env ruby

    require 'rubygems'
    require 'iphoto2'

    if ARGV.length == 1
    data = IPhoto2.new(ARGV[0])
    data.albums.each { |a| puts a.name }
    elsif ARGV.length == 2
    data = IPhoto2.new(ARGV[0])
    album = data.albums.select { |a| a.name == ARGV[1] }
    fail "Could not find an album named '#{ARGV[1]}'" unless album.length == 1
    album = album[0]
    album.images.each { |img| puts img.path }
    else
    fail "Usage: #{__FILE__} <AlbumData.xml> [album name]"
    end

    % mkdir /tmp/pics
    % listalbum AlbumData.xml 'Our Cats' | tr '\012' '\000' | xargs -0 -Jx cp x /tmp/pics
    % mogrify -resize '1024>' /tmp/pics/*

    ###############

    So yeah, I'm pleased. Mainly I'm pleased that the iphoto2 gem exists and
    Just Works, but I'm pleased with how easily I did all this. I neglected to
    mention that this mostly (the listalbum and the mogrify) happened on a
    Linux box, and the Mac just supplied the AlbumData.xml and JPG files.

    --Greg
    Gregory Seidman, Mar 10, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Jessee

    date to text formats - neverending story

    David Jessee, Apr 29, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    359
    Leo Muller
    Apr 29, 2004
  2. Steve Wagner

    ASP.Net horrow story and questions...

    Steve Wagner, Oct 17, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    533
    Michiel
    Feb 17, 2005
  3. Max M. Stalnaker

    python success story

    Max M. Stalnaker, Jan 30, 2006, in forum: Python
    Replies:
    3
    Views:
    278
    Steve Holden
    Jan 30, 2006
  4. k3xji
    Replies:
    1
    Views:
    322
    Gabriel Genellina
    Jun 27, 2009
  5. Andrew Jonathan Fine

    Author of a Python Success Story Needs a Job!

    Andrew Jonathan Fine, Dec 28, 2009, in forum: Python
    Replies:
    27
    Views:
    688
    Simon Brunning
    Jan 15, 2010
Loading...

Share This Page