Module: Gluttonberg::Library::QuickMagick::Serialization::ClassMethods
- Defined in:
- lib/gluttonberg/library/quick_magick/image/serialization.rb
Instance Method Summary collapse
-
#from_blob(blob, &proc) ⇒ Object
create an array of images from the given blob data.
-
#read(filename, &proc) ⇒ Object
(also: #open)
create an array of images from the given file.
Instance Method Details
#from_blob(blob, &proc) ⇒ Object
create an array of images from the given blob data
9 10 11 12 13 14 15 |
# File 'lib/gluttonberg/library/quick_magick/image/serialization.rb', line 9 def from_blob(blob, &proc) file = Tempfile.new(QuickMagick::random_string) file.binmode file.write(blob) file.close self.read(file.path, &proc) end |
#read(filename, &proc) ⇒ Object Also known as: open
create an array of images from the given file
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gluttonberg/library/quick_magick/image/serialization.rb', line 18 def read(filename, &proc) info = identify(%Q<"#{filename}">) info_lines = info.split(/[\r\n]/) images = [] info_lines.each_with_index do |info_line, i| images << Image.new("#{filename}", i, info_line) end images.each(&proc) if block_given? return images end |