anchor.diff:        sequence
         (map 'list #'identity sequence)))
   
  +(defun sequencep (x)
  +  (typep x 'sequence))
  +
   (defun read-bytes (stream count)
     (let ((buf (make-array count :element-type '(unsigned-byte 8))))
       (read-sequence buf stream)
  
positive.code:          (samples-per-pixel tiff-image-samples-per-pixel))
        image
      (let ((*byte-order* byte-order)
            (data-offset 0)
            ifd-entries
            out-of-line-ifd-values)
        (let* ((header-start 0)
               (header-end 8)
               (directory-start header-end)
               (directory-pointer directory-start)
               out-of-line-data-start
               out-of-line-data-pointer
               (bytes-per-row (* image-width samples-per-pixel))
               (rows-per-strip
                (compute-rows-per-strip image-length bytes-per-row)))
          (declare (ignore header-start
                           directory-pointer
                           out-of-line-data-start
                           out-of-line-data-pointer))
          (destructuring-bind (strip-offsets strip-byte-counts)
              (apply #'mapcar #'list
                     (loop for i below image-length by rows-per-strip
                        for byte-offset from i by (* rows-per-strip bytes-per-row)
                        collect (list byte-offset 
                                      (- (min (+ i rows-per-strip) image-length) i))))
            (flet ((add-ifd-entry (tag field-type values)
                     (push (make-instance 'ifd-entry
                                          :tag tag
  
negative.code:                            +field-type-long+
                             rows-per-strip)
            
              ;; FIXME! assume 8 bits per sample for the moment!
              (add-ifd-entry 
               +bits-per-sample-tag+ +field-type-short+ '(8 8 8 8))
  
              (add-ifd-entry 
               +samples-per-pixel-tag+ +field-type-short+ samples-per-pixel)
  
              (add-ifd-entry +photometric-interpretation-tag+
                             +field-type-short+
                             +photometric-interpretation-rgb+)
  
              ;; StripByteCounts and StripOffsets
  
              (add-ifd-entry 
               +strip-byte-counts-tag+ +field-type-long+ strip-byte-counts)
            
              (add-ifd-entry 
               +strip-offsets-tag+ +field-type-long+ strip-offsets)
              
              ;; Finally, reverse the ifd-entries list
              (setf ifd-entries
                    (sort ifd-entries #'< :key #'ifd-entry-tag))
  
              (setf oiv-start (+ stream-offset
                                 2 
                                 (* (length ifd-entries) 12)
                                 4)
                    oiv-pointer oiv-start)
  
              (write-int-16 stream (length ifd-entries))
              (incf stream-offset 2)
  
              ;; 5. Write the directory entries
              (loop for entry in ifd-entries
                 do 
                   (write-ifd-entry entry))
  
              (incf stream-offset (* (length ifd-entries) 12))
  
              (setf out-of-line-ifd-entries
                    (nreverse out-of-line-ifd-entries))
            
              ;; 6. Write 0 to indicate that there are no more IFDs
              (write-int-32 stream 0)
              (incf stream-offset 4)
              
              ;; 7. Write the data for each out-of-line directory entry
              (loop for ifd-entry in out-of-line-ifd-entries
                 do 
                 (write-out-of-line-data ifd-entry
                                         :data-relative 
                                         (= (ifd-entry-tag ifd-entry)
                                            +strip-offsets-tag+)))
              ;; 8. Now write out the strip data
              (loop for start in strip-offsets
                 for count in strip-byte-counts
                 do
                   (write-data (subseq (tiff-image-data image)
                                       start
                                       (+ start count))))))))))
  
  (defmacro write-tiff-file (image pathname &rest args)
    `(with-open-file (stream ,pathname
                             :direction :output
                             :element-type :default
                             ,@args)
       (write-tiff-stream ,image stream)
       ,pathname))
  
  (defparameter *image-info-attributes*
    `((,+image-width-tag+ "Image Width")
  