Skip to content

No support for binary images? #21

@PasaOpasen

Description

@PasaOpasen

I have a tiff file with binary pages, as I think (only black and white)

on command

    with pytiff.Tiff(path) as doc:
        for p in range(doc.number_of_pages):
            doc.set_page(p)
            s = doc[:]

it throws error like

Traceback (most recent call last):
  File "pytiff/_pytiff.pyx", line 738, in pytiff._pytiff.Tiff._get
  File "pytiff/_pytiff.pyx", line 679, in pytiff._pytiff.Tiff._load_tiled
pytiff._pytiff.NotTiledError: Image is not tiled!
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/pasa/Job/AprBot/docutable/dreamocr/venv/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3442, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-22-1c974c4f010a>", line 1, in <module>
    doc[:]
  File "pytiff/_pytiff.pyx", line 772, in pytiff._pytiff.Tiff.__getitem__
  File "pytiff/_pytiff.pyx", line 742, in pytiff._pytiff.Tiff._get
  File "pytiff/_pytiff.pyx", line 646, in pytiff._pytiff.Tiff._load_all
  File "pytiff/_pytiff.pyx", line 666, in pytiff._pytiff.Tiff._load_all_grey
  File "pytiff/_pytiff.pyx", line 562, in pytiff._pytiff.Tiff.dtype.__get__
KeyError: 1

also can be useful:

doc.pages[0].tags
Out[23]: 
{<tags.new_subfile_type: 254>: 0,
 <tags.image_width: 256>: 2481,
 <tags.image_length: 257>: 3508,
 <tags.bits_per_sample: 258>: 1,
 <tags.compression: 259>: 4,
 <tags.photometric: 262>: 0,
 <tags.strip_offsets: 273>: 94755735371888,
 <tags.samples_per_pixel: 277>: 1,
 <tags.rows_per_strip: 278>: 3508,
 <tags.strip_byte_counts: 279>: 94755746415520,
 <tags.x_resolution: 282>: 300.0,
 <tags.y_resolution: 283>: 300.0,
 <tags.planar_configuration: 284>: 1,
 <tags.resolution_unit: 296>: 2}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions