smalot / smalot/pdfparser

PNG Images with FlateDecode are corrupt

Open
#496 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug missing or incomplete functionality
Dominant language
PHP
Stars
2.7k
Forks
579
Avg merge
2m
Merged PRs (30d)
1

Description

I try to extract all XObject (images) from the test pdf
test.pdf

Only the not "FlateDecode" jpg are correct decoded (raw jpg data).

the other images are just 0x00... or 0xFF... byte garbage,
I think maybe the plain gzuncompress

call is not enough and the DecodeParms

/DecodeParms << /Predictor 15 /Colors 1 /Columns 1200 /BitsPerComponent 8>>

must be respected too.

I found this old piece of code https://github.com/frapi/frapi/blob/ef50192b6cf336ef2c4c0fc3ad122194e3d0ecde/src/frapi/library/Zend/Pdf/Filter/Compression.php

but without any success.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/Smalot/PdfParser/RawData/FilterHelper.php around the gzuncompress call referenced by the issue, then inspect how DecodeParms are handled for FlateDecode streams. Use the linked test.pdf to reproduce extraction and verify that the affected XObject images are no longer returned as 0x00 or 0xFF byte garbage.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.