PDF file size too large - option to bypass png image recompression?
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 11.2k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
I have a problem with dompdf producing larger file sizes than expected. My document is actually very simple because it consists of a single image inserted with an <img> tag and a short text overlaid on it with an absolutely positioned <div> (it's a voucher with personalized code). The image is mostly line-art so png is a better choice than jpeg both for file size and quality. I took the time to produce a very well compressed png with special software and I managed to get it down to 55 KB from the original 144 KB. However, the resulting pdf containing only this image is 143 KB. As an experiment I used the unoptimized 144 KB original png as the source and the resulting pdf was 147 KB, which was almost the same. Clearly, dompdf recompresses the image, which causes the file size to go up.
I've already learned it here that for certain features dompdf reparses png images. I'm wondering - is it possible to turn off this reparsing an as option? I don't know what features would be missed in doing so but in my case I don't think I need any special features. It's a non-transparent image on white background and that's it. I just want my png to be inserted as is into the pdf document, it this possible?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no file or test; begin by locating dompdf's PNG parsing and recompression path and checking how image options are handled. Done would mean determining whether bypassing recompression is feasible and documenting or testing the resulting behavior for non-transparent PNG images.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100