# Loading a large tif file but only first slice is loaded in openCV

**URL:** <https://forum.opencv.org/t/loading-a-large-tif-file-but-only-first-slice-is-loaded-in-opencv/2453>\
**Category:** Python\
**Tags:** imgcodecs\
**Created:** [March 29, 2021, 11:40am UTC](https://forum.opencv.org/t/loading-a-large-tif-file-but-only-first-slice-is-loaded-in-opencv/2453 "2021-03-29T11:40:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jerika](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/jerika/32/1606_2.png) [@Jerika](https://forum.opencv.org/u/Jerika)\
**Post date:** [March 29, 2021, 11:40am UTC](https://forum.opencv.org/t/loading-a-large-tif-file-but-only-first-slice-is-loaded-in-opencv/2453/1 "2021-03-29T11:40:54Z")

</div>

Hi ! I’m in a process to write a code in order to process my tiff files .

I manage to load tif files with 20 to 30 slices but when I proceed to work on my original files with 4000 slices only first slice is loaded . I don’t get any type of error. I even proceeded to re-save those files using FIJI image J into tiff files in case the originals were corrupted but same results .

So this print output 1 instead of 4000 slice . Again if I test with small piece of my original file with only 20 slices I get indeed 20 .

```auto
etval, mats = cv.imreadmulti(tif, flags=cv.IMREAD_GRAYSCALE)
    print(len(mats))

```

Opencv version : 4.5.1 Python version : 3.8.3

Any explanation or suggestion would be greatly appreciated .

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [March 29, 2021, 11:47am UTC](https://forum.opencv.org/t/loading-a-large-tif-file-but-only-first-slice-is-loaded-in-opencv/2453/2 "2021-03-29T11:47:56Z")

</div>

unfortunately, support for tiff files is quite sparse in opencv.

rather try to use libtiff directly, not the imread() wrappers.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [March 29, 2021, 4:47pm UTC](https://forum.opencv.org/t/loading-a-large-tif-file-but-only-first-slice-is-loaded-in-opencv/2453/3 "2021-03-29T16:47:08Z")

</div>

OpenCV must recently have gained the functions imreadmulti and imwritemulti

you seem to have encountered a bug! feel free to submit it as an issue on github (and check if it already exists before submitting)
