Class: Image

Inherits:
CommitPhoto show all
Defined in:
lib/commitphotos/image.rb

Constant Summary

Constants inherited from CommitPhoto

CommitPhoto::VERSION

Instance Method Summary collapse

Methods inherited from CommitPhoto

image, #setup_hook, video

Constructor Details

#initializeImage

Returns a new instance of Image.



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/commitphotos/image.rb', line 2

def initialize
  tempfile = Tempfile.new(Time.now.to_i.to_s)
  file = tempfile.path

  `#{dir}/imagesnap -w 2 -q #{file}`

  begin
    image = MiniMagick::Image.open file
    image.resize '800x800>'
    image.write file
    post(File.open file)
  rescue => e
    abort "Unable to capture photo: #{e.message}"
  ensure
    tempfile.unlink
  end
end