     4 read endian>
     4 read endian> <ifd-entry> ;
 
-: read-ifds ( tiff -- tiff )
-    dup ifd-offset>> seek-absolute seek-input
+: read-ifds ( tiff offset -- tiff )
+    seek-absolute seek-input
     2 read endian>
     dup [ read-ifd ] replicate
     4 read endian>
-    [ <ifd> push-ifd ] [ 0 = [ read-ifds ] unless ] bi ;
+    [ <ifd> push-ifd ] [ dup 0 = [ drop ] [ read-ifds ] if ] bi ;
 
 ERROR: no-tag class ;
 

        { 1 [ photometric-interpretation-black-is-zero ] }
        { 2 [ photometric-interpretation-rgb ] }
        { 3 [ photometric-interpretation-palette-color ] }
        [ bad-photometric-interpretation ]
    } case ;

SINGLETONS: compression
compression-none
compression-CCITT-2
compression-lzw
compression-pack-bits ;
ERROR: bad-compression n ;
: lookup-compression ( n -- compression )
    {
        { 1 [ compression-none ] }
        { 2 [ compression-CCITT-2 ] }
        { 5 [ compression-lzw ] }
        { 32773 [ compression-pack-bits ] }
        [ bad-compression ]
    } case ;


: lookup-sample-format ( sequence -- object )
    [
        {
            { 0 [ sample-format-none ] }
            { 1 [ sample-format-unsigned-integer ] }
            { 2 [ sample-format-signed-integer ] }
            { 3 [ sample-format-ieee-float ] }
