    # File lib/prawn/images.rb, line 60
        def image(file, options={})
          Prawn.verify_options [:at, :position, :vposition, :height,
                                :width, :scale, :fit], options

          if file.respond_to?(:read)
            image_content = file.read
          else
            raise ArgumentError, "#{file} not found" unless File.file?(file)
            image_content =  File.binread(file)
          end

          image_sha1 = Digest::SHA1.hexdigest(image_content)

          # if this image has already been embedded, just reuse it
          if image_registry[image_sha1]
            info = image_registry[image_sha1][:info]
            image_obj = image_registry[image_sha1][:obj]
          else
            # build the image object and embed the raw data
            image_obj = case detect_image_format(image_content)
            when :jpg then
              info = Prawn::Images::JPG.new(image_content)
              build_jpg_object(image_content, info)
            when :png then
              info = Prawn::Images::PNG.new(image_content)
              build_png_object(image_content, info)
            end
            image_registry[image_sha1] = {:obj => image_obj, :info => info}
          end

          # find where the image will be placed and how big it will be
          w,h = calc_image_dimensions(info, options)

          if options[:at]
            x,y = map_to_absolute(options[:at])
          else
            x,y = image_position(w,h,options)
            move_text_position h
          end

          # add a reference to the image object to the current page
          # resource list and give it a label
          label = "I#{next_image_id}"
          page.xobjects.merge!( label => image_obj )

          # add the image to the current page
          instruct = "\nq\n%.3f 0 0 %.3f %.3f %.3f cm\n/%s Do\nQ"
          add_content instruct % [ w, h, x, y - h, label ]

          return info
        end