Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

create image from base64 ruby

start_regex = /data:image/[a-z]{3,4};base64,/
filename ||= SecureRandom.hex

regex_result = start_regex.match(base64_data)
if base64_data && regex_result
  start = regex_result.to_s
  tempfile = Tempfile.new(filename)
  tempfile.binmode
  tempfile.write(Base64.decode64(base64_data[start.length..-1]))
end
Source by gist.github.com #
 
PREVIOUS NEXT
Tagged: #create #image #ruby
ADD COMMENT
Topic
Name
3+9 =