# Big tiff problem again.

**URL:** https://discourse.itk.org/t/big-tiff-problem-again/2329
**Category:** Uncategorized
**Created:** [October 17, 2019, 3:57am UTC](https://discourse.itk.org/t/big-tiff-problem-again/2329 "2019-10-17T03:57:55Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![Gib](https://discourse.itk.org/user_avatar/discourse.itk.org/gib/32/4124_2.png) [@Gib](https://discourse.itk.org/u/Gib)
#### Post date: [October 17, 2019, 3:57am UTC](https://discourse.itk.org/t/big-tiff-problem-again/2329/1 "2019-10-17T03:57:55Z")

</div>

I am again encountering problems working with a tiff \> 2GB. (I inquired about a similar problem previously, and three of my posts were removed for being ads or promotional - it doesn’t make any sense to me.)  
I have used ITK to create a 3D tiff (from 400 slices) that is a bit bigger than 2GB. It is not recognized by irfanview-64 or by Fiji. If I reduced the number of slices to 350 everything is OK. I don’t understand where the 2GB restriction is coming from. I thought maybe it was a Windows issue, but in that case surely I would not be able to create the tiff to start with.

Suggestions welcome.  
Gib

---

<div class="post-metadata">

### Author: ![dclunie](https://discourse.itk.org/user_avatar/discourse.itk.org/dclunie/32/2178_2.png) [@dclunie](https://discourse.itk.org/u/dclunie)
#### Post date: [October 17, 2019, 8:45am UTC](https://discourse.itk.org/t/big-tiff-problem-again/2329/2 "2019-10-17T08:45:58Z")

</div>

[https://www.awaresystems.be/imaging/tiff/bigtiff.html](https://www.awaresystems.be/imaging/tiff/bigtiff.html)

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [October 17, 2019, 1:43pm UTC](https://discourse.itk.org/t/big-tiff-problem-again/2329/3 "2019-10-17T13:43:23Z")

</div>

It looks like the last significant [refactoring of TIFF code](https://itk.org/pipermail/insight-users/2014-November/051280.html) was done by @blowekamp back in 2014. 2GB is the limit where ITK decides to write BigTIFF instead of the regular TIFF.

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [October 17, 2019, 2:14pm UTC](https://discourse.itk.org/t/big-tiff-problem-again/2329/4 "2019-10-17T14:14:16Z")

</div>

@dzenanz Is correct at 2GB [itk::TIFFImageIO switches to writing BigTIFF](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/IO/TIFF/src/itkTIFFImageIO.cxx#L612). Technically, regular tiff files can support large, but due to potential (maybe actual?) problems with 32-bit signed integer math 2GB is the decision point.

I have had some success and some problems writing TIFFs with ITK then reading with Fiji. Scalar images seem to work well, but multi-components image I have had problems.

Can you please share the specifics of you Image size, pixel type and number of components?

Fiji uses [SCIFIO](https://github.com/scifio/scifio) so there may be some compatibility that could be improved on both ends.  
@ctrueden

---

<div class="post-metadata">

### Author: ![Gib](https://discourse.itk.org/user_avatar/discourse.itk.org/gib/32/4124_2.png) [@Gib](https://discourse.itk.org/u/Gib)
#### Post date: [October 17, 2019, 7:48pm UTC](https://discourse.itk.org/t/big-tiff-problem-again/2329/5 "2019-10-17T19:48:51Z")

</div>

Thanks to David, Dzenan and Bradley.  
My slices are 2160x2560, 8-bit. There is only one component.  
The 400-page 3D tiff is 2,160,183 KB.  
The message from Fiji is “File is not in a supported format”  
Irfanview appears to open the file, but thinks it has only 2 pages. In the case of the compressed file it thinks it has 4 pages.  
Could the fact that I’m using ITK-4.7.2 be relevant?

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [October 17, 2019, 8:05pm UTC](https://discourse.itk.org/t/big-tiff-problem-again/2329/6 "2019-10-17T20:05:29Z")

</div>

> [@Gib](#):
>
> My slices are 2160x2560, 8-bit. There is only one component.

> [@Gib](#):
>
> Could the fact that I’m using ITK-4.7.2 be relevant?

Yes, that version is quite old.

I was able to write tiff images with SimpleITK 1.2.3, and then read the with Fiji which recovered the correct volume size with a little SimpleITK script:

```auto
import SimpleITK as sitk
img = sitk.Image([2160, 2560, 400], sitk.sitkUInt8)
writer = sitk.ImageFileWriter()
writer.SetImageIO("TIFFImageIO")
writer.SetUseCompression(True)
writer.SetFileName("test_compressed.tif")
writer.Execute(img)

```

---

<div class="post-metadata">

### Author: ![Gib](https://discourse.itk.org/user_avatar/discourse.itk.org/gib/32/4124_2.png) [@Gib](https://discourse.itk.org/u/Gib)
#### Post date: [October 17, 2019, 8:07pm UTC](https://discourse.itk.org/t/big-tiff-problem-again/2329/7 "2019-10-17T20:07:20Z")

</div>

OK, it’s about time I installed a recent version. Are there any gotchas?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [October 17, 2019, 8:58pm UTC](https://discourse.itk.org/t/big-tiff-problem-again/2329/8 "2019-10-17T20:58:33Z")

</div>

You will probably need to make minor modifications to your code, especially if you want to build ITK with disabled legacy code. A [migration guide](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Documentation/ITK5MigrationGuide.md) is available. In case something is missing from it, please let us know or [submit a PR](https://github.com/InsightSoftwareConsortium/ITK/blob/master/CONTRIBUTING.md) yourself.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [October 17, 2019, 8:59pm UTC](https://discourse.itk.org/t/big-tiff-problem-again/2329/9 "2019-10-17T20:59:43Z")

</div>

In case you really don’t want to migrate to ITKv5, you could use [version 4.13.2+](https://github.com/InsightSoftwareConsortium/ITK/tree/release-4.13).

---

<div class="post-metadata">

### Author: ![Gib](https://discourse.itk.org/user_avatar/discourse.itk.org/gib/32/4124_2.png) [@Gib](https://discourse.itk.org/u/Gib)
#### Post date: [October 17, 2019, 9:10pm UTC](https://discourse.itk.org/t/big-tiff-problem-again/2329/10 "2019-10-17T21:10:32Z")

</div>

Thanks Dzenan. I just tried to build 5.0.1, and discovered that it needs VS 2015, but I only have VS 2012. Will version 4.13.2+ build with VS 2012?

---

<div class="post-metadata">

### Author: ![Gib](https://discourse.itk.org/user_avatar/discourse.itk.org/gib/32/4124_2.png) [@Gib](https://discourse.itk.org/u/Gib)
#### Post date: [October 17, 2019, 10:16pm UTC](https://discourse.itk.org/t/big-tiff-problem-again/2329/11 "2019-10-17T22:16:13Z")

</div>

I answered my own question - now building with VS 2012.  
I first made the mistake of downloading the 4.13.2 zip file at [https://itk.org/ITK/resources/software.html](https://itk.org/ITK/resources/software.html), but this gave cmake errors. Using the github file all is OK.

I built version 4.13.2, but the behaviour with these tiffs is identical to 4.7.2, as far as I can tell. Looking at the responses to an earlier query I made on this subject, I see that Curtis Rueden suggested using the SCIFIO plugin in ImageJ to read big tiffs. This works.

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [October 18, 2019, 2:25pm UTC](https://discourse.itk.org/t/big-tiff-problem-again/2329/12 "2019-10-18T14:25:51Z")

</div>

> [@Gib](#):
>
> I see that Curtis Rueden suggested using the SCIFIO plugin in ImageJ to read big tiffs.

Yes, My FIJI was automatically using SCIFIO when I said it was working.

---

<div class="post-metadata">

### Author: ![Gib](https://discourse.itk.org/user_avatar/discourse.itk.org/gib/32/4124_2.png) [@Gib](https://discourse.itk.org/u/Gib)
#### Post date: [October 18, 2019, 11:32pm UTC](https://discourse.itk.org/t/big-tiff-problem-again/2329/13 "2019-10-18T23:32:00Z")

</div>

I had to turn on SCIFIO in Fiji.
