Skip to content

NotImplementedError: unsupported filter /RunLengthDecode #2011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stefan6419846 opened this issue Jul 25, 2023 · 3 comments · Fixed by #2012
Closed

NotImplementedError: unsupported filter /RunLengthDecode #2011

stefan6419846 opened this issue Jul 25, 2023 · 3 comments · Fixed by #2012
Assignees
Labels
workflow-images From a users perspective, image handling is the affected feature/workflow

Comments

@stefan6419846
Copy link
Collaborator

Explanation

The RunLengthDecode filter does not seem to be implemented.

It seems like a corresponding example file is very easy to create by just running ImageMagick on a PDF file of your choice: convert -density 300 -units PixelsPerInch test_document.pdf -alpha off out.pdf (example: out.pdf)

Code Example

reader = PdfReader('tmp/out.pdf')
page = reader.pages[0]
for image in page.images:
    print(image)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/user/lib/python3.9/site-packages/pypdf/_page.py", line 2604, in __iter__
    yield self[i]
  File "/home/user/lib/python3.9/site-packages/pypdf/_page.py", line 2600, in __getitem__
    return self.get_function(lst[index])
  File "/home/user/lib/python3.9/site-packages/pypdf/_page.py", line 522, in _get_image
    imgd = _xobj_to_image(cast(DictionaryObject, xobjs[id]))
  File "/home/user/lib/python3.9/site-packages/pypdf/filters.py", line 854, in _xobj_to_image
    data = x_object_obj.get_data()  # type: ignore
  File "/home/user/lib/python3.9/site-packages/pypdf/generic/_data_structures.py", line 956, in get_data
    decoded._data = decode_stream_data(self)
  File "/home/user/lib/python3.9/site-packages/pypdf/filters.py", line 634, in decode_stream_data
    raise NotImplementedError(f"unsupported filter {filter_type}")
NotImplementedError: unsupported filter /RunLengthDecode
@pubpub-zz
Copy link
Collaborator

to force RunLengthDecode you should add -compress RLE
however thanks for report and test set:
the image (for test):
RL

pubpub-zz added a commit to pubpub-zz/pypdf that referenced this issue Jul 25, 2023
@pubpub-zz
Copy link
Collaborator

@stefan6419846 PR is available if you want to test it

@stefan6419846
Copy link
Collaborator Author

@pubpub-zz Just did a quick test with my original failing file and it seems to work correctly. Thanks.

@pubpub-zz pubpub-zz added the workflow-images From a users perspective, image handling is the affected feature/workflow label Jul 26, 2023
MartinThoma pushed a commit that referenced this issue Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
workflow-images From a users perspective, image handling is the affected feature/workflow
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants