def format(format, page = 0, read_opts={})
      if @tempfile
        new_tempfile = MiniMagick::Utilities.tempfile(".#{format}")
        new_path = new_tempfile.path
      else
        new_path = Pathname(path).sub_ext(".#{format}").to_s
      end

      input_path = path.dup
      input_path << "[#{page}]" if page && !layer?

      MiniMagick::Tool::Convert.new do |convert|
        read_opts.each do |opt, val|
          convert.send(opt.to_s, val)
        end
        convert << input_path
        yield convert if block_given?
        convert << new_path
      end

      if @tempfile
        destroy!
        @tempfile = new_tempfile
      else
        File.delete(path) unless path == new_path || layer?
      end

      path.replace new_path
      @info.clear

      self
    end
def format(format, page = 0, read_opts={})
      if @tempfile
        new_tempfile = MiniMagick::Utilities.tempfile(".#{format}")
        new_path = new_tempfile.path
      else
        new_path = Pathname(path).sub_ext(".#{format}").to_s
      end

      input_path = path.dup
      input_path << "[#{page}]" if page && !layer?

      MiniMagick::Tool::Convert.new do |convert|
        read_opts.each do |opt, val|
          convert.send(opt.to_s, val)
        end
        convert << input_path
        yield convert if block_given?
        convert << new_path
      end

      if @tempfile
        destroy!
        @tempfile = new_tempfile
      else
        File.delete(path) unless path == new_path || layer?
      end

      path.replace new_path
      @info.clear

      self
    end
This is used to change the format of the image. That is, from "tiff to
 jpg" or something like that. Once you run it, the instance is pointing to
 a new file with a new extension!

 *DANGER*: This renames the file that the instance is pointing to. So, if
 you manually opened the file with Image.new(file_path)... Then that file
 is DELETED! If you used Image.open(file) then you are OK. The original
 file will still be there. But, any changes to it might not be...

 Formatting an animation into a non-animated type will result in
 ImageMagick creating multiple pages (starting with 0).  You can choose
 which page you want to manipulate.  We default to the first page.

 If you would like to convert between animated formats, pass nil as your
 page and ImageMagick will copy all of the pages.

 @param format [String] The target format... Like 'jpg', 'gif', 'tiff' etc.
 @param page [Integer] If this is an animated gif, say which 'page' you
   want with an integer. Default 0 will convert only the first page; 'nil'
   will convert all pages.
 @param read_opts [Hash] Any read options to be passed to ImageMagick
   for example: image.format('jpg', page, {density: '300'})
 @yield [MiniMagick::Tool::Convert] It optionally yields the command,
   if you want to add something.
 @return [self]