Q:

writing image data to file in ruby using rmagick

I want to write image to a file using rmagick. Given below is my code
im = "base64encodedstring"
image = Magick::Image.from_blob(Base64.decode64(im)
image[0].format = "jpeg"
name ="something_temp"
path = "/somepath/" + name
File.open(path, "wb") { |f|
    f.write(image[0])
}

I have also tried to use f.write(image). But what get written in the file is #<Magick::Image:0x7eff0587f838>. What is the reason for this?

A:

This should work:
image[0].write(path)

