AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
July 2005

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2005.07.21 15:33 "Help, I need to do some binary surgery on my tiff.", by James Carroll
2005.07.21 15:58 "Re: Help, I need to do some binary surgery on my tiff.", by Joris Van Damme
2005.07.21 18:28 "Re: Help, I need to do some binary surgery on my tiff.", by James Carroll

2005.07.21 18:28 "Re: Help, I need to do some binary surgery on my tiff.", by James Carroll

> You could try to locate the offset to the second IFD, and simply write 
> zero to that. That's 'commenting out', for sure, but I don't know if it's 
> going to help. http://www.awaresystems.be/imaging/tiff/faq.html#q3 
> should probably contain all the information you need to build that.

Hello Joris!  Thanks for your guidance, it worked!

First I had to do my own copy that copied just under 4GB of the file
to a new file, then I found the first IFD, and overwrite the offset
to the next IFD with a zero.

tiffcp still tells me "Seek error accessing tiff directory"
but my own code that reads the file with libtiff can view it!

I wrote the program to do the zeroing in python, and I don't want
to include the destructive lines of code, but here's how I read the
tags:

    f = open(filename,  "r+b")

    # struct:  h is a signed 16 bit integer, 
    # and L is an unsigned 32 bit integer
    (order, version, offset) = struct.unpack('hhL', f.read(8))
    print "header: order", hex(order), "version", version, "offset",
hex(offset), offset

    f.seek(offset)
    (numtags,) = struct.unpack('h', f.read(2))
    print "numtags", numtags
    bytesToSkip = numtags * 12
    f.seek(bytesToSkip, 1)
    (nextIfd,) = struct.unpack('L', f.read(4))
    print "next ifd offset:", hex(nextIfd),  nextIfd

the final step was to seek backward four bytes, then 
write four bytes of 0.

Thanks,
-Jim