Skip to content

Commit

Permalink
Use Vectory for all detection
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeymorozov committed Dec 14, 2023
1 parent a39dcbc commit 3e13eda
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions lib/isodoc/presentation_function/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3e13eda

Please sign in to comment.