def get_file_type
         type = nil
         read = []
         open_file do |file|

           # Check if the file is a JPEG.
           read_source(file, read, 2)
           if read[0,2] == [255, 216]
              type = JPEG
           else
              # Check if it's a PNG.
              read_source(file, read, 6)
              if read[0,8] == [137, 80, 78, 71, 13, 10, 26, 10]
                 type = PNG
              else
                 # Check if its a bitmap.
                 if read[0,2] == [66, 77]
                    size = to_integer(read[2,4])
                    type = BITMAP if size == File.size(@source)
                 end
              end
           end

         end

         type
      end
def get_file_type
         type = nil
         read = []
         open_file do |file|

           # Check if the file is a JPEG.
           read_source(file, read, 2)
           if read[0,2] == [255, 216]
              type = JPEG
           else
              # Check if it's a PNG.
              read_source(file, read, 6)
              if read[0,8] == [137, 80, 78, 71, 13, 10, 26, 10]
                 type = PNG
              else
                 # Check if its a bitmap.
                 if read[0,2] == [66, 77]
                    size = to_integer(read[2,4])
                    type = BITMAP if size == File.size(@source)
                 end
              end
           end

         end

         type
      end
This method attempts to determine the image type associated with a
 file, returning nil if it fails to make the determination.