Module: Rabbit::Parser::Ext::Image
- Included in:
- RD::Ext::Image
- Defined in:
- lib/rabbit/parser/ext/image.rb
Defined Under Namespace
Modules: Private
Class Method Summary collapse
Class Method Details
.make_image(canvas, uri_str, prop = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/rabbit/parser/ext/image.rb', line 30 def make_image(canvas, uri_str, prop={}) path = Private.uri_string_to_image_filename(canvas, uri_str) begin Element::Image.new(path, prop) rescue Error canvas.logger.warn($!.) nil end end |
.make_image_from_file(canvas, source) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rabbit/parser/ext/image.rb', line 40 def make_image_from_file(canvas, source) src_file = Tempfile.new("rabbit-image-source") src_file.open src_file.print(source) src_file.close image_file = prop = nil begin image_file, prop = yield(src_file.path) rescue ImageLoadError canvas.logger.warn($!.) end return nil if image_file.nil? image = make_image(canvas, %Q[file://#{image_file.path}], prop) return nil if image.nil? image["_src"] = image_file # for protecting from GC image end |