Skip to content

PNG image quality degradation and rendering issues in 3.0.2 due to fast-png integration #3885

@vulture9

Description

@vulture9

Description:

Problem Summary
After upgrading from jsPDF 3.0.1 to 3.0.2, certain PNG images rendered from base64 data appear severely blurred/corrupted in the generated PDF, while the same images render perfectly in 3.0.1.

Root Cause Analysis
The issue appears to be related to the integration of fast-png library in version 3.0.2. The fast-png parser has stricter PNG format compliance requirements and different image processing behavior compared to the previous PNG handling in 3.0.1.

Reproduction
Works in: 3.0.1
Broken in: 3.0.2+
Image format: PNG base64
Behavior: Some PNG images render correctly, others become blurred/corrupted

Image

Do you have an idea why it is happening, are you aware about it?

It happens for the images 16-bit PNG,
8-bit PNG works fine.

I have tried with loading local project asset and via external URL with the same effect.
no projeblems in version 3.0.1

fast-png seems not to be handling 16-bit images well, would be nice to have a proper check on your side and fallback with some canvas processing solution with conversion to jpeg, unless you have some other suggestions and I`m missing something?

Looks like soley reliance on fast-png might be a mistake...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions