def image_to_file(file)
      raise ArgumentError, "Expected #{String}, got #{file.class}." unless file.is_a?(String)
      # Split the file name in case of multiple fragments:
      parts = file.split('.')
      if parts.length > 1
        base = parts[0..-2].join
        extension = '.' + parts.last
      else
        base = file
        extension = ''
      end
      # Get the binary image strings and dump them to the file(s):
      images = image_strings
      images.each_index do |i|
        if images.length == 1
          f = File.new(file, 'wb')
        else
          f = File.new("#{base}-#{i}#{extension}", 'wb')
        end
        f.write(images[i])
        f.close
      end
    end
def image_to_file(file)
      raise ArgumentError, "Expected #{String}, got #{file.class}." unless file.is_a?(String)
      # Split the file name in case of multiple fragments:
      parts = file.split('.')
      if parts.length > 1
        base = parts[0..-2].join
        extension = '.' + parts.last
      else
        base = file
        extension = ''
      end
      # Get the binary image strings and dump them to the file(s):
      images = image_strings
      images.each_index do |i|
        if images.length == 1
          f = File.new(file, 'wb')
        else
          f = File.new("#{base}-#{i}#{extension}", 'wb')
        end
        f.write(images[i])
        f.close
      end
    end
Dumps the binary content of the Pixel Data element to the specified file.

 If the DICOM object contains multi-fragment pixel data, each fragment
 will be dumped to separate files (e.q. 'fragment-0.dat', 'fragment-1.dat').

 @param [String] file a string which specifies the file path to use when dumping the pixel data
 @example Dumping the pixel data to a file
   dcm.image_to_file("exported_image.dat")