Skip to content

Instantly share code, notes, and snippets.

@kevinthompson
Last active June 27, 2017 20:29
Show Gist options
  • Save kevinthompson/a1450bfa2b8c6888aca527f0c7b3ada4 to your computer and use it in GitHub Desktop.
Save kevinthompson/a1450bfa2b8c6888aca527f0c7b3ada4 to your computer and use it in GitHub Desktop.
Script for Displaying Images on #SIGNALconf Interactive Display

Notes

This requires you to have a few things:

  1. A Mac
  2. An iPhone
  3. A US Cell Phone Number
  4. Handoff Enabled on Your Mac/iPhone
  5. A generous text message plan

Image

This script isn't currently doing any resizing. It assumes you're sending an image with the dimenions of 76x25. transparent pixels will be ommitted.

Command

With the required gems installed, you can run this by either making the script an executable, or invoking it through ruby and passing it the path to the image you want to display:

ruby display.rb unicorn.png
require 'rmagick'
class Image
attr_reader :filepath
def initialize(filepath:)
@filepath = filepath
end
def display
image_file.each_pixel do |pixel, x, y|
if pixel.opacity == 0
send_message "Move #{x}, #{y}"
send_message "Color #{pixel.to_color}"
end
end
end
private
def image_file
Magick::Image::read(filepath).first
end
def send_message(message)
`osascript -e '\
tell application "Messages" \
to send "#{message}" \
to buddy "744625"'`
sleep 1
end
end
image = Image.new(filepath: ARGV[0])
image.display
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment