Posted in

Process iCloud PhotoStream in real-time

  1. Intro
  2. Information
  3. Installation
  4. Examples

Intro

Couple of days ago I released osx-photostream for node.js on Mac OSX with iCloud. It allows you to process PhotoStream uploads as they happen. You can snap a picture with your iPhone, your Mac instantly receives the photo and will notify your script for all sorts of post-processing. All within seconds.

Information

Platform:node.js
Language:javascript
Package:osx-photostream on npm
Source code:Github
Bugs & feedback:Issue tracker
License:Unlicense / Public Domain
Documentation:README.md

Installation

npm install osx-photostream

Examples

Only copy new images to another folder:

require( 'osx-photostream' )( '~/Pictures/iCloud' );

Do more stuff with them:

var ps = require( 'osx-photostream' )();

ps.on( 'update', function( file ) {
    console.log( 'New image added: ' + file.filename );
});

Or do both and first copy to another folder, then tell another app a new image is ready using AppleScript.

var ps = require( 'osx-photostream' )( '~/Pictures/iCloud' );
var exec = require( 'child_process' ).exec;

ps.on( 'copy', function( file ) {
  // Forward image to friend
  exec( 'osascript -e "tell application \"Messages\" to send POSIX file \"' + file.copypath + '\" to buddy \"friend@email.tld\" of service \"E:my@email.tld\""' );
});

Leave a Reply

Your email address will not be published. Required fields are marked *