Class: OSX::CIImage

Inherits:
Object
  • Object
show all
Defined in:
lib/capture/extensions.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from(filepath) ⇒ Object

Raises:

  • (Errno::ENOENT)


13
14
15
16
# File 'lib/capture/extensions.rb', line 13

def self.from(filepath)
  raise Errno::ENOENT, "No such file or directory - #{filepath}" unless File.exists?(filepath)
  OSX::CIImage.imageWithContentsOfURL(OSX::NSURL.fileURLWithPath(File.expand_path(filepath)))
end

Instance Method Details

#cgimageObject



9
10
11
# File 'lib/capture/extensions.rb', line 9

def cgimage
  OSX::NSBitmapImageRep.alloc.initWithCIImage(self).CGImage()
end

#save(target, format = OSX::NSJPEGFileType, properties = nil) ⇒ Object



3
4
5
6
7
# File 'lib/capture/extensions.rb', line 3

def save(target, format = OSX::NSJPEGFileType, properties = nil)
  bitmapRep = OSX::NSBitmapImageRep.alloc.initWithCIImage(self)
  blob = bitmapRep.representationUsingType_properties(format, properties)
  blob.writeToFile_atomically(File.expand_path(target), false)
end