question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Png with transparency is added twice

See original GitHub issue

Bug Report

Description of the problem

When I try to insert a png with transparency into the document, the image is inserted twice.

this is the image: https://drive.google.com/file/d/1Paci2YPG0PAvnvNgGlVazkn3cL8txICt/view?usp=sharing

this is the output pdf https://drive.google.com/file/d/1O3sRSiHnLCpRkiflb7tjzWfxGh7xbvSf/view?usp=sharing

Code sample

const PDFDocument = require('pdfkit');
const fs = require('fs');

  const doc = new PDFDocument( {
    layout: 'portrait',
    size: 'letter',
    margin: 0,
  });

  doc.image('./google0.026317087946030382.png', 0 ,0 , { width: 150, height: 100});

  const pdfFile = `./output.pdf`;
  doc.pipe(fs.createWriteStream(pdfFile));
  doc.end();  

Your environment

  • pdfkit version: ^0.8.3
  • Node version: v8.10.0
  • Operating System: ubuntu:16.04 and Windows 10

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
swftvsncommented, Jan 9, 2019

we use https://github.com/lovell/sharp to preprocesses image on the fly to produce consistent results across wide variety of images. It handles multiple formats so we can accept images in many formats and produce predictable pdfs without worrying about users supplying webp or other formats.

0reactions
blikblumcommented, Jan 30, 2019

Version 0.9 should fix thix

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why this png image appears twice? - Stack Overflow
So, the image is appearing twice because you put the image src to be the logoehands.png and in the CSS you put background-image, ......
Read more >
Why Is My PNG Not Transparent Photoshop? - website builder
There are a few reasons why your PNG might not be transparent in Photoshop. One reason is that you are using the wrong...
Read more >
What Is the Alpha Channel in PNG Images? - MakeUseOf
Here's everything you need to know about the alpha channel in PNG images. ... if you want to add transparency, you have to...
Read more >
Masks -- IM v6 Examples - ImageMagick
It saves the transparency channel as a 'matte' image file format, and required two separate steps, and commands to define the right image...
Read more >
Sorting out Problems with Transparency - Mozilla Hubs
Not every .PNG contains alpha (transparency) information. The author of the image needs to have explicitly added it. Fortunately, it's not that ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found