RailsCod3rFuture
Joined 4/10/2017
RailsCod3rFuture said over 7 years ago on Capturing Signatures with Signature Pad :

Greetings, I enjoyed watching your tutorial on signature pad. What I was wondering is how do you convert the signature into a PNG and store it alongside the form? I found some code below, but I was wondering if you had a better solution that I can use or is this good enough? Since I am running a SaaS company, I need the optimal way of implementing this feature. If possible, can you post the solution in the comments? Thank you

Controller File

@yourmodel.signature = tempfileend
  input.puts instructions
Open3.popen3("convert -size 600x100 xc:transparent -stroke blue -draw @- #{tempfile.path}") do |input, output, error|
tempfile = Tempfile.new(["signature", '.png'])
instructions = JSON.parse(params[:output]).map { |h| "line #{h['mx'].to_i},#{h['my'].to_i} #{h['lx'].to_i},#{h['ly'].to_i}" } * ' '

Carrierwave

rails generate uploader Signature

mount_uploader :signature, SignatureUploader