Skip to content

Instantly share code, notes, and snippets.

@xarimanx
Created March 4, 2014 07:56
Show Gist options
  • Save xarimanx/9342063 to your computer and use it in GitHub Desktop.
Save xarimanx/9342063 to your computer and use it in GitHub Desktop.
base 64 to Image
def signature_to_img(data, filename)
return if data.blank?
FileUtils.mkdir_p(File.dirname(filename))
instructions = JSON.parse(data).map { |h| "line #{h['mx'].to_i},#{h['my'].to_i} #{h['lx'].to_i},#{h['ly'].to_i}" }.join(' ')
Open3.popen3("convert -size 198x55 xc:transparent -stroke blue -draw @- #{filename}") do |input, output, error|
input.puts instructions
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment