#!/ruby
# coding: utf-8

require 'rmagick'

xml = <<XML
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-5000 -5000 10000 10000">
  <polygon fill="#726658" stroke="#000000" stroke-miterlimit="10"
   points="3363.922,708.127 2224.154,704.127 2224.154,28.668   2380.791,29.004 2381.784,-226.69 3211.861,-226.69 3211.692,28.979 3363.922,28.643 "/>
</svg>
XML

File.open('source.svg', 'w'){ |file| file.write(xml) }

Magick::Image.from_blob(xml) do
  self.format = 'SVG'
  self.background_color = 'transparent'
end.tap do |images|
  image = images.first
  
  image.write('untrimmed.png')
  image.trim.write('trimmed.png')
end
