Class: Vectory::Ps
Instance Attribute Summary
Attributes inherited from Vector
#initial_path
Attributes inherited from Image
#content
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Vector
#file_size, from_datauri, from_path, #initialize, #mime, #path, #size, #to_uri, #write
Methods inherited from Image
from_content, from_path, #initialize
Class Method Details
.default_extension ⇒ Object
7
8
9
|
# File 'lib/vectory/ps.rb', line 7
def self.default_extension
"ps"
end
|
.from_node(node) ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/vectory/ps.rb', line 15
def self.from_node(node)
return from_content(node.children.to_xml) unless node.text.strip.empty?
uri = node["src"]
return Vectory::Datauri.new(uri).to_vector if %r{^data:}.match?(uri)
from_path(uri)
end
|
.mimetype ⇒ Object
11
12
13
|
# File 'lib/vectory/ps.rb', line 11
def self.mimetype
"application/postscript"
end
|
Instance Method Details
#height ⇒ Object
48
49
50
51
52
53
|
# File 'lib/vectory/ps.rb', line 48
def height
bbox = parse_bounding_box
return super unless bbox
bbox[:ury] - bbox[:lly]
end
|
#to_emf ⇒ Object
28
29
30
|
# File 'lib/vectory/ps.rb', line 28
def to_emf
to_pdf.to_emf
end
|
#to_eps ⇒ Object
24
25
26
|
# File 'lib/vectory/ps.rb', line 24
def to_eps
to_pdf.to_eps
end
|
#to_pdf ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/vectory/ps.rb', line 36
def to_pdf
pdf_content = GhostscriptWrapper.convert(content, eps_crop: false)
pdf = Pdf.new(pdf_content)
bbox = parse_bounding_box
if bbox
pdf.original_width = bbox[:urx] - bbox[:llx]
pdf.original_height = bbox[:ury] - bbox[:lly]
end
pdf
end
|
#to_svg ⇒ Object
32
33
34
|
# File 'lib/vectory/ps.rb', line 32
def to_svg
Svg.from_content(Postsvg.convert(content))
end
|
#width ⇒ Object
55
56
57
58
59
60
|
# File 'lib/vectory/ps.rb', line 55
def width
bbox = parse_bounding_box
return super unless bbox
bbox[:urx] - bbox[:llx]
end
|