From 3e13eda8a5bcf9ea84fc8ee17400483ce8395344 Mon Sep 17 00:00:00 2001 From: Alexey Morozov Date: Thu, 14 Dec 2023 15:08:38 +0100 Subject: [PATCH] Use Vectory for all detection --- lib/isodoc/presentation_function/image.rb | 38 ++++++++++++++--------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/lib/isodoc/presentation_function/image.rb b/lib/isodoc/presentation_function/image.rb index a38ed7b2..99898d16 100644 --- a/lib/isodoc/presentation_function/image.rb +++ b/lib/isodoc/presentation_function/image.rb @@ -110,24 +110,32 @@ def emf_to_svg(img) def eps_to_svg(node) pp "Runnings eps_to_svg" - uri = eps_to_svg_uri(node) - ret = imgfile_suffix(uri, "svg") - File.exist?(ret) and return ret + # uri = eps_to_svg_uri(node) # to path, from inline (converted to datauri) or datauri (saved to path) or path? + # ret = imgfile_suffix(uri, "svg") + # File.exist?(ret) and return ret # cache? # inkscape_convert(uri, ret, "--export-plain-svg") - Vectory::Eps.from_path(uri).to_svg.write.path - # pp "called" - # if node.text.strip.empty? - # pp "text empty" - # uri = node["src"] - # ret = imgfile_suffix(uri, "svg") - # File.exist?(ret) and return ret - # Vectory::Eps.from_path(uri).to_svg.write(ret).path - # else - # pp "else" - # a = Base64.strict_encode64(node.children.to_xml) + # Vectory::Eps.from_path(uri).to_svg.write.path + pp "called" + if node.text.strip.empty? + pp "text empty" + uri = node["src"] + if %r{^data:}.match?(uri) + pp "data match" + Vectory::Datauri.new(uri).to_vector.to_svg.write.path + else + pp "no data, else => path" + ret = imgfile_suffix(uri, "svg") + File.exist?(ret) and return ret + Vectory::Eps.from_path(uri).to_svg.write(ret).path + end + else + pp "else => inline" + content = node.children.to_xml + Vectory::Eps.from_content(content).to_svg.write.path + # a = Base64.strict_encode64(content) # datauri_src = "data:application/postscript;base64,#{a}" # Vectory::Datauri.new(datauri_src).to_vector.to_svg.write.path - # end + end end def svg_to_emf(node)