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
13 14 15 16 17 18 19 20 21 |
# File 'lib/rabbit/parser/ext/image.rb', line 13 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
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rabbit/parser/ext/image.rb', line 23 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 |