Sha256: 62d04acb6d86418255c31a132b6b67c2756fe5bafa182a9fbf85d8a8000e774e

Contents?: true

Size: 841 Bytes

Versions: 6

Compression:

Stored size: 841 Bytes

Contents

# frozen_string_literal: true

require "emf2svg"

module Vectory
  class Emf < Vector
    def self.default_extension
      "emf"
    end

    def self.all_mimetypes
      [mimetype] + alternative_mimetypes
    end

    def self.mimetype
      "image/emf"
    end

    def self.alternative_mimetypes
      ["application/x-msmetafile"]
    end

    def self.from_node(node)
      uri = node["src"]
      return Vectory::Datauri.new(uri).to_vector if %r{^data:}.match?(uri)

      from_path(uri)
    end

    def to_svg
      with_file("emf") do |input_path|
        content = Emf2svg.from_file(input_path).sub(/<\?[^>]+>/, "")

        Svg.from_content(content)
      end
    end

    def to_eps
      convert_with_inkscape("--export-type=eps", Eps)
    end

    def to_ps
      convert_with_inkscape("--export-type=ps", Ps)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vectory-0.7.3 lib/vectory/emf.rb
vectory-0.7.2 lib/vectory/emf.rb
vectory-0.7.1 lib/vectory/emf.rb
vectory-0.7.0 lib/vectory/emf.rb
vectory-0.6.0 lib/vectory/emf.rb
vectory-0.5.0 lib/vectory/emf.rb