Last Updated: February 25, 2016
·
657
· gouravtiwari

Save image in resources

Save image in resources directory with 'bubble-wrap':

imageData = UIImage.UIImageJPEGRepresentation(@image_view.image, 1)
encodedData = [imageData].pack("m0")
data = {"image" => encodedData }
unpack = data["image"].unpack("m0")
@image_name = Time.now.to_s.gsub(/:|-| /,'')

File.open("#{App.resources_path}/#{@image_name}.jpg", "w+b") do |f|
  f.write(unpack.first)
end