-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
jsPDF images are corrupted when using large, smartphone-captured jpegs #3318
Comments
Is it a JPEG or JPEG2000 / other variation?
On Mon, 15 Nov 2021 at 10:58, Howard G Ricketts ***@***.***> wrote:
I've been trying to use the version 2.4.0 of jspdf to create a PDF
containing images. However, the images are corrupted (basically just
vertical stripes of grey).
The issues appears to be mainly affect jpegs that are captured from the
camera directly. If you take a picture, crop it a little bit smaller and
re-save it then it normally displays OK.
I've got a demo hosted at: https://upbeat-franklin-22e659.netlify.app/
that's written in knockout.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3318>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAALTMYDONLQFICZJYDSLODUMDRULANCNFSM5IBMH5GQ>
.
--
James Hall
Director
Parallax
Office: +44 113 322 6477
Mobile: +44 7894 950320
Web: https://parall.ax
• Northern Tech 100 - Four Years Running
• Top 50 Digital Agencies in the North - Four Years Running
• A Yorkshire & Humberside Top 50 Tech Firm
• One of the Top 25 Fastest-Growing Tech Businesses in Leeds
• ISO 9001 & ISO 27001 Certified
Registered office: Parallax, The Elbow Rooms, 64 Call Lane, Leeds, LS1 6DT
Registered in England no. 07430032
VAT No. 101 3405 84
|
I found a workaround for this. If you render it into a canvas first, the orientation of the image is fixed, and the distortion goes away. var canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
canvas.width = img.width;
canvas.height = img.height;
context?.drawImage(img, 0, 0);
doc.addImage({
imageData: canvas,
... |
I think we had a canvas fallback few versions ago. I think I removed it because canvas is not working in node and uses I think alot of memory. |
I'm facing this same issue, and I have a link to image which I add like this: I do not understand how to use this workarounce. Would it be possible to explain a little bit more, if I might be so bold to ask? |
In my example you need
Or maybe it's possible to use |
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. |
The issue is still valid, as the canvas workaround causes extreme slowness |
We've been hit with this issue as well, and have determined a cause and a fix. I have put through pull request (#3667) to address this issue. The problem is with these markers used for This means The non-cropped image supplied by @molorosh (see below) has a C4 marker before the C0 marker. Because of this, the wrong sizing is determined. Removing the C4 marker from the list of markers allows it to find the C0 marker and get the correct size. |
Any updates on the PR status? |
I've been trying to use the version 2.4.0 of jspdf to create a PDF containing images. However, the images are corrupted (basically just vertical stripes of grey).
The issues appears to be mainly affect jpegs that are captured from the camera directly. If you take a picture, crop it a little bit smaller and re-save it then it normally displays OK.
I've got a demo hosted at: https://upbeat-franklin-22e659.netlify.app/ that's written in knockout.
The text was updated successfully, but these errors were encountered: