Class: Knj::RSVGBIN

Inherits:
Object show all
Defined in:
lib/knj/rsvgbin.rb

Class Method Summary collapse

Class Method Details

.convert_file(file_from, file_to) ⇒ Object



14
15
16
17
18
19
# File 'lib/knj/rsvgbin.rb', line 14

def self.convert_file(file_from, file_to)
  RSVGBIN.test_version
  
  png_content = RSVGBIN.png_content_from_file(file_from)
  Php.file_put_contents(file_to, png_content)
end

.png_content_from_file(file_from) ⇒ Object



9
10
11
12
# File 'lib/knj/rsvgbin.rb', line 9

def self.png_content_from_file(file_from)
  RSVGBIN.test_version
  return %x[rsvg-convert #{Strings.unixsafe(file_from)}]
end

.test_versionObject



2
3
4
5
6
7
# File 'lib/knj/rsvgbin.rb', line 2

def self.test_version
  test_version = %x[rsvg-convert -v]
  if !test_version.match(/^rsvg-convert version [0-9\.]+$/)
    raise "No valid version of rsvg-bin was found."
  end
end