Created
March 4, 2014 07:56
-
-
Save xarimanx/9342063 to your computer and use it in GitHub Desktop.
base 64 to Image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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