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
RangeError: offset is out of bounds: Some PNG filters are not processable #3004
Comments
I just tried to replicate this issue and played a bit around with the image in Gimp. I found out that the image in question has
I have no idea what making this change means in context of the code, but it would be nice if this could be solved in the code 🙈 |
@michaelzangerle could you may try to fix this in the code? Since you already found out the reason for the issue, I think it should not be that hard to fix this in code. |
@HackbrettXXX I just tried a bit around with GIMP as I am also affected by this issue in a project and had similar issues in the past. But I am afraid I am no JS developer and have no idea what this change of the image mode means in terms of the code here. Sorry 🙈 If I can be of some help otherwise I will gladly do so. |
This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant. |
As @michaelzangerle has stated above, you need to change the color profile of your image to work, that is the current workaround. |
@tarekis sorry for the late answer, being busy at work. That really helped and made me go throw the issue. Thank you so much for the clarification. |
Adding PNGs via
addImage
with certain filters throws an error:Please bear with me, I am certainly no expert on images, but I'd like to relay my findings on this error.
Some PNG images cannot be processed if they are directly added with
addImage
via URL (previously I have included them by creating a data URL from a canvas).The issue is this code that seems to apply PNG filters: https://github.com/MrRio/jsPDF/blob/82d3b7d72861e06c4c167ec562715c6734c3f709/src/modules/png_support.js#L167
Previous method VS new method for context
Previous method
New method
This was changed because now this generation happens in a offloaded worker, which no longer can access canvases BTW.
This can be worked around by changing the image source to a JPEG, that still works.
This does not occur on all PNG images, but only on certain ones, what exactly determines it will fail I don't know, but it seems it has nothing to do with the image mode (indexed/RGB/CMYK all seem to behave the same), I have tested a series of images for products where you can see the material the products are made of, all with the same material pattern fail, some other material patterns all work, which means of images by the same source - that probably have different filters because of the different materials - some fail and some don't
I have uploaded one failing image to imgur, you can replicate the error by opening the live demo and adding this code:
The text was updated successfully, but these errors were encountered: