[ome-users] BigTIFF OME-TIFFs do not meet the BigTIFF standard
Melissa Linkert
melissa at glencoesoftware.com
Thu Nov 29 23:56:03 GMT 2012
Hi Matthias,
> I have used your code snippet but I get the same result with it:
> Libtiff 4.0.2 fails to open BigTIFF OME-TIFFs with big endian byte order.
>
> According to the BigTIFF specification, the first eight bytes are grouped in four groups with two bytes each (datatype = word).
> For me, it seems that the first eight bytes of BigTIFF OME-TIFFs only consist of three groups. Two two-byte groups and one four-byte group.
> Therefore, BigTIFF OME-TIFFs with little endian byte order are valid because the position of the number 8 is correct.
> But for BigTIFF OME-TIFFs with big endian byte order, the number 8 should be two positions towards the left side.
Thank you for clarifying - the critical detail is that this is only a
problem when writing big-endian files.
> In the Java class "TiffSaver", I found the following line in the writeHeader() method:
> out.writeInt(8);
> As this line will always write four bytes at once, I think it should be replaced by:
> if (bigTiff) {
> out.writeShort(8);
> out.writeShort(0);
> }else out.writeInt(8);
This works for me as well, and so has been turned into a patch to be reviewed
for inclusion:
https://github.com/openmicroscopy/bioformats/pull/258
Regards,
-Melissa
On Wed, Nov 28, 2012 at 11:46:10PM +0100, Matthias Baldauf wrote:
> Hi Melissa,
>
> thank you for your response!
> I have used your code snippet but I get the same result with it:
> Libtiff 4.0.2 fails to open BigTIFF OME-TIFFs with big endian byte order.
>
> According to the BigTIFF specification, the first eight bytes are grouped in four groups with two bytes each (datatype = word).
> For me, it seems that the first eight bytes of BigTIFF OME-TIFFs only consist of three groups. Two two-byte groups and one four-byte group.
> Therefore, BigTIFF OME-TIFFs with little endian byte order are valid because the position of the number 8 is correct.
> But for BigTIFF OME-TIFFs with big endian byte order, the number 8 should be two positions towards the left side.
>
> In the Java class "TiffSaver", I found the following line in the writeHeader() method:
> out.writeInt(8);
> As this line will always write four bytes at once, I think it should be replaced by:
> if (bigTiff) {
> out.writeShort(8);
> out.writeShort(0);
> }else out.writeInt(8);
>
> After changing these lines, TiffSaver creates valid BigTIFFs for both, big & little endian byte order.
> I use the following code snippet to read the first eight bytes:
>
> // -- begin --
> RandomAccessFile ra = new RandomAccessFile(new File(bigometiff), "r");
> for(int i=0; i<8; i++)
> System.out.println(ra.read());
> ra.close();
> // -- end --
>
> I hope I can help you with this information.
>
> Kind regards,
> Matthias
>
More information about the ome-users
mailing list