Create Image From Base64 Ruby

[Solved] Create Image From Base64 Ruby | Ruby - Code Explorer | yomemimo.com
Question : create image from base64 ruby

Answered by : akshay-kakade

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 : https://gist.github.com/simonqian/490302d44d401e7a27f45d200cb2b493 | Last Update : Tue, 21 Jun 22

Answers related to create image from base64 ruby

Code Explorer Popular Question For Ruby