From the Rmagick :
Convert image to another format
Converting an image to another format is as simple as writing an image to a file.
ImageMagick uses the suffix (".jpg" for JPEG, ".gif" for GIF, for example) output file name suffix (".jpg" for JPEG, ".gif" for GIF, for example) or prefix ("ps:" for PostScript, for example) to determine the output image format.
Is there a way to convert an image to memory?
source share