github razvandimescu/gopdf v0.8.5
v0.8.5 — preserve image quality on merge

latest releases: v0.11.2, v0.11.1, v0.11.0...
5 months ago

What's Changed

Bug fix: merged PDFs now preserve image quality byte-exact. Two issues caused visible color fringing/banding and inflated output size on multi-channel images:

  1. PNG predictor decoder ignored bytes-per-pixel. Sub/Average/Paeth filters used current[i-1] as the "left" neighbor; for RGB-8 images (bpp=3) it must be current[i-bpp], so reconstructed pixels were wrong on any non-trivial filter row.
  2. Merge re-encoded streams without DecodeParms. copyStream decoded each non-image stream and re-Flate-compressed without the PNG predictor, ballooning a 9-PDF / 8 MB archive to 15 MB and routing image data through the buggy decoder above.

Reader.readStreamData now exposes the original pre-filter bytes via a new Stream.Raw field; MergeFiles / MergeBytes / MergeWithOptions write them verbatim with the source's Filter/DecodeParms chain. Dedup hashing now reads Raw (encoded size) instead of Data (decoded size) for a large CPU/memory win on big images.

New API

  • Stream.Raw []byte — original pre-filter stream bytes when parsed from a PDF (nil for streams constructed in code). Existing consumers reading Stream.Data (decoded bytes) are unaffected.

Full Changelog: v0.8.4...v0.8.5

Don't miss a new gopdf release

NewReleases is sending notifications on new releases.