Skip to content

Tifimage: problem to use getframe function for stacks of single image files #501

@osholm

Description

@osholm

Apparently, there is a problem in tif image when using getframe to jump to another image. It seems related to tifimage expecting a multi-image file and not a series of images (possibly therefore it doesn't inherit the fabioutils version of getframe).

Example:

imtif = tifimage.tifimage()
imtif.read('Rasterscan-ACT_Raster10deg-2000mu_Export_0010.tiff')
imtif.getframe(30)
Leads to this:
File ~/opt/miniconda3/envs/MyPySide-conda/lib/python3.10/site-packages/fabio/tifimage.py:231, in TifImage.getframe(self, num)
229 tiff_header = self._tiffio.getInfo(num)
230 return self._create_frame(image_data, tiff_header)
--> 231 raise Exception("getframe out of range")

Exception: getframe out of range

it ends up here in tifimage.py:

   if 0 <= num < self.nframes:
        image_data = self._tiffio.getData(num)
        tiff_header = self._tiffio.getInfo(num)
        return self._create_frame(image_data, tiff_header)
    raise Exception("getframe out of range")

where nframes is 1 because of only having one image in the file.

The code has changed quite a bit since I last looked at it, so I am unsure if I am expected to use another function for jumping to another file in the stack of tiffs but generally it should capture that it is a series (actually .next() and .previous() does work) and therefore try to goto to another file if there is no stack of images in the file itself, or?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions