# TIFF images flipped in vtkTIFFReader

**URL:** <https://discourse.vtk.org/t/tiff-images-flipped-in-vtktiffreader/1033>\
**Category:** Development\
**Created:** [May 27, 2019, 7:09pm UTC](https://discourse.vtk.org/t/tiff-images-flipped-in-vtktiffreader/1033 "2019-05-27T19:09:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cryos](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cryos/32/35_2.png) [@cryos](https://discourse.vtk.org/u/cryos)\
**Post date:** [May 27, 2019, 7:09pm UTC](https://discourse.vtk.org/t/tiff-images-flipped-in-vtktiffreader/1033/1 "2019-05-27T19:09:11Z")

</div>

I have been looking into an issue with the vtkTIFFReader, and commit [84f9a173d81](https://github.com/Kitware/VTK/commit/84f9a173d81a774dcbe49e174596a5a2a0fd6a71#diff-1e304d89f67f99c46014ac463af13d11) made by @lorensen in 2014. The line that confuses me is:

```
const bool flip = this->InternalImage->Orientation != ORIENTATION_TOPLEFT;

```

This is opposite to what I would expect, where `vtkImageData` has its origin in the bottom-left, and so with an orientation in top-left I would expect that to cause the image to be flipped, i.e. `==` rather than `!=`. Is there something I am missing. In a simple test I get a single page TIFF, and it is flipped opposite to what my system viewer renders in Tomviz.

I can propose a patch making all of these `==` and it would fix my issue, maybe there is something about tiled TIFFs I don’t appreciate (I use multi-page, but not tiled).

---

<div class="post-metadata">

**Author:** ![cryos](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cryos/32/35_2.png) [@cryos](https://discourse.vtk.org/u/cryos)\
**Post date:** [May 27, 2019, 7:29pm UTC](https://discourse.vtk.org/t/tiff-images-flipped-in-vtktiffreader/1033/2 "2019-05-27T19:29:32Z")

</div>

I can fix the bug I am seeing by switching `FlipTrue` and `FlipFalse` in `vtkTIFFReader::ReadGenericImage` which I wrote in 2014 to speed up reading of files. I would appreciate a second opinion in case I am missing something as everything seems to be geared to only flip if not top-left. It seems like we only really support bottom-left and top-left correctly from looking through the code.

---

<div class="post-metadata">

**Author:** ![cryos](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cryos/32/35_2.png) [@cryos](https://discourse.vtk.org/u/cryos)\
**Post date:** [May 28, 2019, 10:59pm UTC](https://discourse.vtk.org/t/tiff-images-flipped-in-vtktiffreader/1033/3 "2019-05-28T22:59:42Z")

</div>

I posted a branch and am letting buildbot test it now, [https://gitlab.kitware.com/vtk/vtk/merge\_requests/5596](https://gitlab.kitware.com/vtk/vtk/merge_requests/5596) has the patch, and comparing to ImageJ, Gwenview, system preview the image matches what is expected.
